A
Alex Hardin
Hey,
I just downloaded Visual C++ 2005 Express, and I'm reading through a
book called "Visual C++ .NET Step By Step", which was made for 2003.
Just so you know where I'm getting this example.
When I build this code, I get the following compile error.
1>c:\documents and settings\editing\my
documents\alex\c++\animal\animal\animal.cpp(6) : fatal error C1190:
managed targeted code requires a '/clr' option
And that is regarding this:
#using <mscorlib.dll>
And then when I had /clr to the options, it then says:
1>cl : Command line error D8016 : '/RTC1' and '/clr' command-line
options are incompatible
So if I shut off /RTC1 in code generation, then it just says that
therer is another thing incompatible (/Gm I think) and it just keeps
going on with incompatibilities. Is there any way that I can make this
code work?
////////////////////////////////////////////////////////////////////////
// Animal.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
__gc class Animal
{
public:
int legs;
void SetName(String *name)
{ strName = strName->Copy(name); }
String* GetName() { return strName; }
private:
String *strName;
};
int _tmain()
{
Animal *cat, *dog;
cat = new Animal;
dog = new Animal;
cat->SetName("Cat");
cat->legs = 4;
dog->SetName("Dog");
dog->legs = 4;
Console::WriteLine("Animal 1");
Console::Write("Name: ");
Console::WriteLine(cat->GetName());
Console::Write("Legs: ");
Console::Write(cat->legs);
return 0;
}
//////////////////////////////////////////////////////
I am using a regular Win32 console applications. Thanks alot.
I just downloaded Visual C++ 2005 Express, and I'm reading through a
book called "Visual C++ .NET Step By Step", which was made for 2003.
Just so you know where I'm getting this example.
When I build this code, I get the following compile error.
1>c:\documents and settings\editing\my
documents\alex\c++\animal\animal\animal.cpp(6) : fatal error C1190:
managed targeted code requires a '/clr' option
And that is regarding this:
#using <mscorlib.dll>
And then when I had /clr to the options, it then says:
1>cl : Command line error D8016 : '/RTC1' and '/clr' command-line
options are incompatible
So if I shut off /RTC1 in code generation, then it just says that
therer is another thing incompatible (/Gm I think) and it just keeps
going on with incompatibilities. Is there any way that I can make this
code work?
////////////////////////////////////////////////////////////////////////
// Animal.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
__gc class Animal
{
public:
int legs;
void SetName(String *name)
{ strName = strName->Copy(name); }
String* GetName() { return strName; }
private:
String *strName;
};
int _tmain()
{
Animal *cat, *dog;
cat = new Animal;
dog = new Animal;
cat->SetName("Cat");
cat->legs = 4;
dog->SetName("Dog");
dog->legs = 4;
Console::WriteLine("Animal 1");
Console::Write("Name: ");
Console::WriteLine(cat->GetName());
Console::Write("Legs: ");
Console::Write(cat->legs);
return 0;
}
//////////////////////////////////////////////////////
I am using a regular Win32 console applications. Thanks alot.