J
JKop
Is this them all?:
class Dummy
{
public:
Dummy() {}
Dummy(const Dummy& original) { }
Dummy& operator=(const Dummy& lhs) {}
const Dummy * operator&() const { return this; }
Dummy * operator&() { return this; }
~Dummy() {}
};
Also could anyone please inform me of circumstances in which these are
edited and in which they disappear? For example I'm already aware of the
following:
1) Dummy() disappears if you supply another one that takes arguments, eg.
Dummy(int).
2) operator= and the copy constructor will change for every extra member
variable that's added to the class.
--
Now, take the following:
int main()
{
int j;
}
I'm fully aware that j contains no particular value, it hasn't been
initialized.
Now take the following:
int main()
{
int j = 45;
}
I'm fully aware that that's equal to:
int j = int(45);
But, where you have user-defined types, what exactly goes on?
For instance:
SomeClass k = 78.222;
Does that become:
SomeClass k = SomeClass(78.222);
And then is the SomeClass(const SomeClass&) copy constructor called? Or...
does the compiler simply look for a different copy constructor, eg.
SomeClass(const double&)? Or is that even valid?
Anyway here's what I'm getting at: I know int() is equal to zero, ie. if you
specify brackets then it gets intialized to zero. Now ofcourse you have the
problem of:
int main()
{
int j();
}
The compiler doesn't know if it's an object definition or a function
declaration (...if only "extern" was compulsory). As such, it assumes a
function declaration.
Is the only way to get around this to write:
int j(0);
?
Anyway here comes my question:
class Chocolate
{
public:
int a;
double b;
};
int main()
{
Chocolate choco;
}
Do "a" and "b" get initialized to zero? And if so, what does it? Is it the
miranda default constructor? What about in the following code:
class Chocolate
{
public:
int a;
double b;
Chocolate() {}
};
int main()
{
Chocolate choco;
}
Do "a" and "b" get initialized to zero in the above?
-JKop
class Dummy
{
public:
Dummy() {}
Dummy(const Dummy& original) { }
Dummy& operator=(const Dummy& lhs) {}
const Dummy * operator&() const { return this; }
Dummy * operator&() { return this; }
~Dummy() {}
};
Also could anyone please inform me of circumstances in which these are
edited and in which they disappear? For example I'm already aware of the
following:
1) Dummy() disappears if you supply another one that takes arguments, eg.
Dummy(int).
2) operator= and the copy constructor will change for every extra member
variable that's added to the class.
--
Now, take the following:
int main()
{
int j;
}
I'm fully aware that j contains no particular value, it hasn't been
initialized.
Now take the following:
int main()
{
int j = 45;
}
I'm fully aware that that's equal to:
int j = int(45);
But, where you have user-defined types, what exactly goes on?
For instance:
SomeClass k = 78.222;
Does that become:
SomeClass k = SomeClass(78.222);
And then is the SomeClass(const SomeClass&) copy constructor called? Or...
does the compiler simply look for a different copy constructor, eg.
SomeClass(const double&)? Or is that even valid?
Anyway here's what I'm getting at: I know int() is equal to zero, ie. if you
specify brackets then it gets intialized to zero. Now ofcourse you have the
problem of:
int main()
{
int j();
}
The compiler doesn't know if it's an object definition or a function
declaration (...if only "extern" was compulsory). As such, it assumes a
function declaration.
Is the only way to get around this to write:
int j(0);
?
Anyway here comes my question:
class Chocolate
{
public:
int a;
double b;
};
int main()
{
Chocolate choco;
}
Do "a" and "b" get initialized to zero? And if so, what does it? Is it the
miranda default constructor? What about in the following code:
class Chocolate
{
public:
int a;
double b;
Chocolate() {}
};
int main()
{
Chocolate choco;
}
Do "a" and "b" get initialized to zero in the above?
-JKop