医学影像与核医学考研:关于C++.NET的问题,

来源:百度文库 编辑:高校问答 时间:2024/04/28 06:12:09
我是C++初学者,在使用VS C++.NET 2003编写C++程序时,创建项目时选择的是控制台应用程序(.NET),不知是否正确,如果正确,怎样使用cout和cin来输入输出呢?也就是说用头文件iostream来进行程序编写.因为我们学习时是以C++6.0,基本就是用那个头文件

如果你会C#,学.NET Console应该比较快。否则还是老老实实用win32 Console吧。

下面是三个版本的Hello world,自己比较比较:

//win32 Console
// hello.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

int _tmain(int argc, _TCHAR* argv[])
{
std::cout<<"hello world"<<std::endl;
return 0;
}

//或者

#include "stdafx.h"
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
cout<<"hello world"<<endl;
return 0;
}

//C#
using System;

namespace Hello
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
Console.WriteLine("hello world");
//
}
}
}

//.NET Console Application
#include "stdafx.h"

#using <mscorlib.dll>

using namespace System;

int _tmain()
{
Console::WriteLine(S"Hello World");
return 0;
}

include<stdio.h>
void main()
......
printf("唉 我也是初学 不会 只是帮你捧场而已");
......