ICloneableを使用した学校プロジェクトを構築しています。これは非常に単純なプロジェクトですが、このエラーを通過できないようです。
MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Users\Ed\Documents\Visual Studio 2012\School_Projects\Cpp Programs\CppInterfaceProgramming\Debug\CppInterfaceProgramming.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0
プロジェクトは、VS2012を使用してCLRコンソールアプリケーションとしてセットアップされます。正しいアプリケーションを選択したと確信しています。
これは私に問題を与えているコードです:
/*
TestCloning class provides for testing of Circle and Square classes
*/
#include "stdafx.h"
#include "Square.h"
#include "Circle.h"
using namespace System;
ref class TestCloning
{
private: static ConsoleKeyInfo^ cki;
static Object^ Copy (ICloneable^ o)
{
Object^ newObject = o->Clone();
return newObject;
}
static void main()
{
while (true)
{
copyOrExit();
if (cki->ToString() == "S")
{
displayAndCopySquare();
}
else if (cki->ToString() == "C")
{
displayAndCopyCircle();
}
else if (cki->Key == ConsoleKey::Escape)
{
Environment::Exit(0);
}
}// while
} // main
// provide prompt for user to copy object or exit
static void copyOrExit()
{
Console::WriteLine(L"Press the Escape key to exit, S to display and copy a Square object, " +
"or C to display and copy a Circle object. ");
cki = Console::ReadKey(true);
Console::WriteLine(L"\n");
} // end copyOrExit method
// method to display and copy features of a square based on user input
static void displayAndCopySquare()
{
String^ userInput;
bool isNum;
double sideLength = 0;
while (true)
{
Console::WriteLine(L"Please enter a number representing the length of one side of a squareto "+
"examine and copy...");
userInput = Console::ReadLine();
isNum = double::TryParse(userInput, sideLength);
if (isNum)
{
sideLength = double::Parse(userInput);
break;
}
else
{
Console::WriteLine(L"The value you entered is not a qualified value. Please try again...");
Console::WriteLine("");
}
}// while (true)
// create Square object and display
Square^ mySquare = gcnew Square(sideLength);
Console::WriteLine("The length of one side of this square is " + mySquare->Side);
Console::WriteLine("The perimeter of this square is " + mySquare->Perimeter);
Console::WriteLine("The area of this square is " + mySquare->Perimeter);
// clone square to new object and display
ICloneable^ clonedSquare = mySquare;
Square^ newSquare = (Square^)Copy(clonedSquare);
Console::WriteLine(L"The length of one side of the square clone is " + newSquare->Side);
Console::WriteLine(L"The perimeter of the square clone is " + newSquare->Perimeter);
Console::WriteLine(L"The area of the square clone is " + newSquare->Area);
Console::WriteLine(L"\n");
} // end of displayAndCopySquare method
// method to display and copy features of a circle based on user input
static void displayAndCopyCircle()
{
String^ userInput;
double radius = 0;
bool isNum;
while (true)
{
Console::WriteLine(L"Please enter an integer representing the radius of a circle to examine and copy");
userInput = Console::ReadLine();
isNum = double::TryParse(userInput, radius);
if (isNum)
{
radius = double::Parse(userInput);
break;
}
else
{
Console::WriteLine(L"The value you entered is not a qualified value. Please try again...");
Console::WriteLine(L"\n");
}
} // while loop
// create circle object and display
Circle^ myCircle = gcnew Circle(radius);
Console::WriteLine(L"The radius of this circle is " + myCircle->Radius);
Console::WriteLine(L"The circumference of this circle is " + myCircle->Circumference);
Console::WriteLine(L"The area of this circle is " + myCircle->Area);
// clone circle to new object and display
ICloneable^ clonedCircle = myCircle;
Circle^ newCircle = (Circle^)Copy(clonedCircle);
Console::WriteLine(L"The radius of this circle clone is " + newCircle->Radius);
Console::WriteLine(L"The circumference of this clircle clone is " + newCircle->Circumference);
Console::WriteLine(L"The area of this circle clone is " + newCircle->Circumference);
Console::WriteLine(L"\n");
} // end displayAndCopyCircle
};