[Solved] Accessing a data member of a pointer [closed]

[ad_1] It works just fine: http://ideone.com/3E5Uec #include <iostream> using std::cout; using std::endl; class Cat { public: int name; Cat() : name(0) { } int getName() { return name; } }; int main() { Cat* pointer = new Cat(); pointer->name = 42; cout << “getName: ” << pointer->getName() << endl; cout << “name: ” << pointer->name … Read more

[Solved] How do I use a JavaScript variable in PHP? [closed]

[ad_1] Javascript and PHP don’t actually know anything about one another. However, you can use PHP to write to JavaScript. So in my_functions.php you could do this: <?php $myGlobalSongIndex = ‘0’; // or however you want to assign this else…. ?> <script type = “text/javascript”> var song_index = <?php print myGlobalSongIndex; ?>; Then in shortcodes.php … Read more

[Solved] Build frame for page content using CSS [closed]

[ad_1] Except for header background, you won’t need any other images. You can use a div for header with image background and 100% width, another div as the outer “square” with background and border and padding/margin, then div with white background and border radius (http://www.w3schools.com/cssref/css3_pr_border-radius.asp). (You could also do gradient from header background by using … Read more

[Solved] Validating School Year [closed]

[ad_1] Assuming that 2013-2014 is a valid format, this might be a function that works: public static bool IsSchoolYearFormat(string format, int minYear, int maxYear) { string[] parts = format.Trim().Split(new[] { ‘-‘ }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 2) { int fromYear; int toYear; if (int.TryParse(parts[0], out fromYear) && int.TryParse(parts[1], out toYear)) { if (fromYear >= minYear … Read more

[Solved] How can I use the same name for two or more different variables in a single C# function? [closed]

[ad_1] You can make the scopes non-overlapping using braces: switch (something) { case 1: { int Number; } break; case 2: { float Number; } break; } Going out of scope is the only way a variable name is “deleted” in the sense you are talking about. Notably and unlike some other languages, C# doesn’t … Read more

[Solved] Facebook app that automatically writes on fans wall, when some fan have birthday? [closed]

[ad_1] Luckily, this is not possible, as it would be pure spam. You would need to authorize every single User with the App, request the publish_actions and user_birthday permissions and store an Extended User Token (that is valid for 60 days). You will never get publish_actions approved by Facebook in their review process, because it´s … Read more

[Solved] Since when does 3 / 5 = 0?

[ad_1] The / operator looks at its operands and when it discovers that they are two integers it returns an integer. If you want to get back a double value then you need to cast one of the two integers to a double double difference = (endX – startX + 1) / (double)ordinates; You can … Read more

[Solved] C# method signatures – restricting types – what’s the correct terminology? [closed]

[ad_1] I think the term you are looking for is generic type constraints. From the linked MSDN article: When you define a generic class, you can apply restrictions to the kinds of types that client code can use for type arguments when it instantiates your class. If client code tries to instantiate your class by … Read more

[Solved] C++ if x more than y by 3

[ad_1] The expression (x[i] > y) is a boolean, which in this context is casted as an integer (0 or 1), but hardly ever reaches 3. So the branch will always be skipped. If your values x[i] and y are integers, just take the difference: if (x[i] – y == 3) {…} If those are … Read more

[Solved] remove white space before comma

[ad_1] You need to use: $(‘[data-title=”Score”]’).text().replace(/ \,/g, ‘,’); //or .replace(” ,”, ‘,’); for single occurence if you want to replace the text : $(‘[data-title=”Score”]’).text(function( index,text ) { return text.replace(/ \,/g, ‘,’); //or .replace(” ,”, ‘,’); for single occurence }); Working Demo 3 [ad_2] solved remove white space before comma

[Solved] Naming a variable based on another variable

[ad_1] No, you can’t, and it makes no sense honestly to have a feature like that. If you want , you can use a dictionary, where you can have the key be a string: Dictionary<string, RectangleShape> shapes = new Dictionary<string, RectangleShape>(); shapes.Add(“nameTheKey”, new RectangleShape( … )); Then you can simply read the “variable” like shapes[“nameTheKey”] … Read more

[Solved] Create a js object from the output of a for loop

[ad_1] A simple Array.prototype.reduce with Object.assign will do // objectMap reusable utility function objectMap(f,a) { return Object.keys(a).reduce(function(b,k) { return Object.assign(b, { [k]: f(a[k]) }) }, {}) } var arr = { “a”: “Some strings of text”, “b”: “to be encoded”, “c”: “& converted back to a json file”, “d”: “once they’re encoded” } var encodedValues … Read more

[Solved] jQuery – do something once AJAX complete [duplicate]

[ad_1] You can do this: $.post(url, data, function () { alert(“success”); // Call the custom function here myFunction(); }); Or this: // Assign handlers immediately after making the request, // and remember the jqxhr object for this request var jqxhr = $.post(url, data); jqxhr.done(function () { alert(“second success”); // Call the custom function here myFunction(); … Read more