declaration

Is it correct to use declaration only for empty private constructors in C++?

For example is this correct: class C { private: C(); C(const & C other); } or you should rather provide definition(s): class C { private: C() {}; C(const & C other) {}; } ? Thanks for the current answers. Let's extend this question - does compiler generate better code in one of this examples? I can im...

Declaring an Array using Variables and the array() construct in PHP

I'm sure this has been asked before but I can't find it. The PHP documentation unclear on this and I can't find any examples like this. Is it legal to use variables in the declaration of an array use the array() construct? Not as keys, as the values. Like this: function myFunc($value1, $value2, $value3) { $myArr = array('value1'...

friend function declared inside befriended class, GCC does not compile

Hello, I've got following code: File: Foo.h class Foo { friend void Bar(); }; File: Foo.cpp void Bar() {}; File Test.cpp #include "Foo.h" int main(void) { Bar(); return 0; } VS2008 compiles this without any error or warning. G++ 4.3.4 reports: test.cpp: In function ‘int main()’: test.cpp:8: error: ‘Bar’ was not d...

The RSS Feed of Wordpress blog goes wild

Hi, I've installed the wordpress.org script however the RSS feed just sends me errors. I've tried to edit files within the wordpress like wp-rss2.php to remove "?" from the first line but it does not work and I am not sure what else could be wrong. The feed is here: http://www.donaha.sk/feed I haven't found anything on Mr. Google so f...

How to know in C# code which type a variable was declared with

I want to have some function that would return "Base" if a variable of class Base was passed to it, "Derived" if it was declared as Derived, etc. Not depending on runtime type of a value it was assigned to. ...

Can anyone explain this array declaration to me?

Hi guys, just wondering the difference between the presence of the last comma in the array, if there is any at all >> [1,2,3] => [1, 2, 3] >> [1,2,3,] => [1, 2, 3] The second array still works, no exception raised Thanks ...

prior declarations of functions

Why do functions need to be prior declared in C ? ...

How to mitigate class declaration being far from its owner namespace declaration in a file?

So, I've seen how useful namespaces can be to organize declarations into their respective groups, but now comes an issue with this. The difference between making a library in C and a library in C++ is in C you must prefix your declarations with what they belong to, for example a library we'll dub MyMath might have a vector class, well t...

C++/CLI : How to declare template array as method parameters

I am a newbie to C++/CLI. What is the equivalent of the following C# code in managed C++/CLI for both the header and source file? public static bool ArrayEquals<T>(T[] a, T[] b) { return true; } ...

Define constraints on the context in which as class is instantiated

I wonder if there's a way to define a class in such a way that instances of it will never be members of another class (only local variables), or the other way round - only members but never local. Is there any way in which a class can dictate the scope of it's prospective instances? ...

C++/CLI : How do I declare abstract (in C#) class and method in C++/CLI?

What is the equivalent of the following C# code in C++/CLI? public abstract class SomeClass { public abstract String SomeMethod(); } ...

Benefits of declaring a function as "inline"?

Every time I read about the "inline" declaration in C it is mentioned that it is only a hint to the compiler (i.e. it does not have to obey it). Is there any benefit to adding it then, or should I just rely on the compiler knowing better than me? ...

C++: Forward declaration of class doesn't seem to work?

The follwing code is compiled in VC++6. I don't understand why I am getting the compilation error "C2079: 'b' uses undefined class 'B'" for the following code? //Class B Source #include "B.h" void B::SomeFunction() { } //Class B Header #include "A.h" struct A; class B { public: A a; void SomeFunction(); }; /...

C++/CLI : Advantages over C#

Is there any major advantage of managed C++/CLI over C#. Definitely not the syntax I suppose as the following code in C++/CLI is real ugly, C++/CLI code: [Out]List<SomeObject^>^% someVariable Compare above with C# Code: out List<SomeObject> someVariable Just out of curiosity, is there an even uglier syntax in C++/CLI as compared t...

XML: Is this valid?

Is the following XML declaration valid? <message metadata="SomeMetaData" xsi:nil="true"/> where xsi is defined as "http://www.w3.org/2001/XMLSchema-instance" If I am trying to create the above data for transfer through a ASP.NET Web Service Application in C#, how do I go about coding the above? Say for example I have a web service m...

Reason for using .prototype in Javascript

What are the technical reasons for using .prototype instead of declaring functions and members inside the object itself. It is easiest to explain with code examples. What are the advantages of using: RobsObject = function(data){ this.instanceID = data.instanceID; this._formButton = document.getElementById('formSubmit_' + this.i...

Efficiency of C Variable Declaration

How long does it take to declare a variable in C, for example int x or unsigned long long var? I am wondering if it would make my code any faster in something like this. for (conditions) { int var = 0; // code } Would it be faster to do this, or is it easier not to? int var; for (conditions) { var = 0; // code } Tha...

Need help reaching a variable in JavaScript

Can someone please help me understand the scoop of JavaScript variables, and how to reach them? Imagine the following... // Namespace declaration var p = {}; p.result = { searchForm: $('#search-form'), searchAction: this.searchForm.attr('action'), anotherSection: { hello: 'Hello ', world: this.hello + 'wo...

Is semicolon really needed after declarations in x++ ?

As said in the book Microsoft Dynamics AX 2009 Programming: Getting Started it´s needed to put semicolons after declarations in x++: The extra semicolon after the variable declaration is mandatory as long as the first line of code is not a keyword. The semicolon tells the compiler that variable declarations have come to an ...

Working with Java arrays

/** * Testing Arrays * @author N002213F * @version 1.0 */ public class JavaArrays { public void processNames(String[] arg) { //-- patented method, stop, do not read ;) } public void test() { // works fine String[] names1 = new String[] { "Jane", "John" }; processNames(names1); /...