2 qq 34170352 qq_34170352 于 2016.09.14 16:34 提问

刚开始学C++,求大神指点这段代码的问题

#include "stdafx.h"

using namespace System;

enum class Suit {Clubs, Diamond, Hearts, Spades};

int main(array ^args)
{
Suit suit = Suit::Clubs;
int value = safe_cast(suit);
Console::WriteLine(L"Suit is {0} and the value is {1} ", suit, value);
suit = Suit::Diamond;
value = safe_cast(suit);
Console::WriteLine(L"Suit is {0} and the vlaue is {1} ", suit, value);
suit = Suit::Hearts;
value = safe_cast(suit);
Console::WriteLine(L"Suit is {0} and the vlaue is {1} ", suit, value);
suit = Suit::Spades;
value = safe_cast(suit);
Console::WriteLine(L"Suit is {0} and the vlaue is {1] ", suit, value);
return 0;
}

用VS 2015 编译好多错误。。。

3个回答

shihengzhen101
shihengzhen101   Rxr 2016.09.14 17:19

你这代码不是C++的吧,看着像C#的。。。

djh123456021
djh123456021   2016.09.14 17:29

这是C++吗?一点也不像

u013095845
u013095845   2016.09.16 12:37

为了解决错误,不仅要上源码,还要传上编译器的错误报告。
另外,如果是刚开始学c++,不要用vs这种有点复杂的编译器。我推荐vc++和dev c++,很多。

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!