G
Guest
Hi
Trying to learn c++ and am woundering over afew things
1) What is the diffrence between . and -> and :: ?
2) Why do you sometimes have to use ^ after declaring a object, what exacly
does it do?
3) What is the diffrence between & and *? (I know that * is a pointer)
4) Managed and Unmanaged code, whats the diffrence?
I am trying to write a simple class:
when i compile i get the following error:
Error 1 error C3265: cannot declare a managed 'mId' in an unmanaged
'PatryManager:arty'
Error 2 error C3265: cannot declare a managed 'mName' in an unmanaged
'PatryManager:arty'
class Party
{
public:
Party();
Party(String^ id);
void NewId();
~Party();
private:
String^ mId;
String^ mName;
};
Party:arty()
{
}
Party:arty(String^ id)
{
mId = id;
}
Party::~Party()
{
// Destroy objects
}
void Party::NewId()
{
Random^ mRandGenerator;
int tempId = 0;
String^ mTemp = String::Empty;
char mLetterA[1];
char mLetterB[1];
tempId = mRandGenerator->Next(1000,9999);
mLetterA[0] = (char)mRandGenerator->Next(1,25);
mLetterB[0] = (char)mRandGenerator->Next(1,25);
mTemp = tempId.ToString() + mLetterA[0] + mLetterB[0];
mId = mTemp;
}
Trying to learn c++ and am woundering over afew things
1) What is the diffrence between . and -> and :: ?
2) Why do you sometimes have to use ^ after declaring a object, what exacly
does it do?
3) What is the diffrence between & and *? (I know that * is a pointer)
4) Managed and Unmanaged code, whats the diffrence?
I am trying to write a simple class:
when i compile i get the following error:
Error 1 error C3265: cannot declare a managed 'mId' in an unmanaged
'PatryManager:arty'
Error 2 error C3265: cannot declare a managed 'mName' in an unmanaged
'PatryManager:arty'
class Party
{
public:
Party();
Party(String^ id);
void NewId();
~Party();
private:
String^ mId;
String^ mName;
};
Party:arty()
{
}
Party:arty(String^ id)
{
mId = id;
}
Party::~Party()
{
// Destroy objects
}
void Party::NewId()
{
Random^ mRandGenerator;
int tempId = 0;
String^ mTemp = String::Empty;
char mLetterA[1];
char mLetterB[1];
tempId = mRandGenerator->Next(1000,9999);
mLetterA[0] = (char)mRandGenerator->Next(1,25);
mLetterB[0] = (char)mRandGenerator->Next(1,25);
mTemp = tempId.ToString() + mLetterA[0] + mLetterB[0];
mId = mTemp;
}