If I say:
x = "abc"
this seems like a declaration, definition and assignment, all at the same time, regardless of whether I have said anything about x in the program before.
Is this correct?
I'm not sure what the correct terminology is in Ruby for declarations, definitions and assigments or if there is even a distinction between thes...
Something I've been taught when I first started with Object Oriented programming languages.
When declaring a field in a class, don't initialize it yet, do that in the constructor.
In C#:
public class Test
{
private List<String> l;
public Test()
{
l = new List<String>();
}
}
But when someone recently asked me why to do t...
Hi.
Simple question, is this valid C++:
class Foo
{
void Foo::doSomething();
};
The point of the question: is that repeated use of the class name and double colon before the method name valid inside the class declaration?
I'm having issues compiling code that does this using g++ 4.2.3. I would love to see a reference to somethin...
Hello,
In JavaScript, it is possible to declare multiple variables like this:
var variable1 = "Hello World!";
var variable2 = "Testing...";
var variable3 = 42;
...or like this:
var variable1 = "Hello World!",
variable2 = "Testing...",
variable3 = 42;
Is one method better/faster than the other?
Thanks,
Steve
...
I have a variable $params which gets data from the database:
$params = mssql_fetch_array($result)
As far as I know, it is associative array. I want another array $tempParams to hold the value of this array. Can I assign it by using the following statement:
$tempParams = $params
In addition, do I need one single statement to decla...
Hi,
I seem to be forgetting my C++ ...
I'm trying to declare some functions in C in separate sources, and including the appropriate .h when necessary. It compiles OK; but the problem is during linking, where the linker complains about functions already being defined.
I even tried defining the functions as extern, in a (vain) attempt ...
I was wondering about little differences between declaration of function prototypes in headers and in .c files. I have a header with some prototype functions and a some .c files with real implementation of these functions. I made some changes in the header, only added "__restrict" qualifier (recognized by gcc). My question is do I have t...
What is the meaning of const in declarations like these? The const confuses me.
class foobar
{
public:
operator int () const;
const char* foo() const;
};
...
This is such a dumb question it's frustrating even asking it. Please, bear with me, I'm feeling particularly dumb over this one today....
I've got a library with a certain typedef struct. basically:
typedef struct {int x; int y;} coords;
What I really wanted to do was declare in my header a variable array of this:
coords MyCoord...
Apologies in advance for what is probably a stupid question, but in C++ classes, why the semi-colon after the closing brace? I regularly forget it and get compiler errors, and hence lost time. Seems somewhat superfluous to me, which is unlikely to be the case. Do people really do things like
class MyClass
{
.
.
.
} MyInstance;
Edit...
Is it possible to declare a variable in c++ without instantiating it? I want to do something like this:
Animal a;
if( happyDay() )
a( "puppies" ); //constructor call
else
a( "toads" );
Basially, I just want to declare a outside of the conditional so it gets the right scope.
Is there any way to do this without using pointers ...
I am having a lot of trouble. I have a function that takes a variable and an associative array, but I can't seem to get them to pass right. I think this has something to do with function declarations, however I can't figure out how they work in Perl. Does anyone know a good reference for this and how to accomplish what I need?
I should a...
I would like to put user controls on pages without registering the tag at the top of the page. For example:
<p>some text</p>
<myname:mycontrol runat="server" />
Is this possible? I've heard that tag declarations can be done in web.config... is this true?
If so, any idea which .NET framework versions support this?
Thanks
...
I initialized a vector of pointers called "antiviral_data", and am able to use antiviral_data.push_back without problems. But when I try to do the same thing with "viral_data" I get an error, because the compiler thinks I am redeclaring "viral_data":
vector<virus*> viral_data;
vector<virus*>::iterator vI;
viral_data.push_back(new X1(9, ...
Hello,
I'm a newbie to C# so please excuse me if I ask dumb questions...
Here is my problem :
I have a class "ProtocolTabPage" that inherits from "TabPage".
I have a "ControlPanel" that inherits from "Panel".
I have a ControlPanel instanced by my ProtocolTabPage.
Both my classes are in the namespace "AutoTestProtocols.Interface".
I...
I know the questions seems ambiguous, but I couldn't think of any other way to put it, but, Is it possible to do something like this:
#include<iostream>
class wsx;
class wsx
{
public:
wsx();
}
wsx::wsx()
{
std::cout<<"WSX";
}
?
...
Why does the following program give me an declaration error?
Aren't I declaring it at that specific line?
#include <iostream>
#define MILLION 1000000
using namespace std;
class BitInt
{
public:
BigInt();
private:
int digit_array[MILLION];
int length;
};
BigInt::BigInt()
{
int length=0;
for(int i=0; i<MILLIO...
Hi,
I have a class and I want to have some bit masks with values 0,1,3,7,15,...
So essentially i want to declare an array of constant int's such as:
class A{
const int masks[] = {0,1,3,5,7,....}
}
but the compiler will always complain.
I tried:
static const int masks[] = {0,1...}
static const int masks[9]; // then initializing ...
Whats the real difference between declaring an array like this:
var myArray = new Array();
and
var myArray = [];
...
I am having a hard time getting this to work
file: myclass.hpp
Class MyClass {
public:
template <class T>
MyClass &operator<<(const T &val);
};
file: myclass.cpp
template <class T>
MyClass &MyClass::operator<<(const T &val) {
...
}
I can compile this in to a object without a problem, But when other functions try to ca...