C++ Cout

Its is displaying Cout as Invalid code on the Visual C++ Compiler

Page 1 of 1

4 Replies - 1541 Views - Last Post: 03 September 2008 - 03:28 PM Rate Topic: -----

#1 x-lil-monroe-x  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 16-March 08

C++ Cout

Post icon  Posted 02 September 2008 - 02:47 PM

// 03092008.h

#pragma once

using namespace System;

namespace My03092008 {

	public ref class Class1
	{


		cout << "This Is my first Program";

		return 0;
	}
}




I Just picked up "C++ - From the ground up Author: Herbert Schildt" And i decided to start today. I entered the code that h said for the first program and it didnt work. His book IS a C++ Standard Book. I have checked That. Btw I am using the Visual C++ COmpiler to generate the other code. E.g NameSpace My.... Whereas The book has different code i think. But that Shouldnt be the problem. Its only Cout afterAll. I will Supply the code If annybody feels The need. ThankYou ! :^:

Is This A Good Question/Topic? 0
  • +

Replies To: C++ Cout

#2 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3106
  • View blog
  • Posts: 19,145
  • Joined: 14-September 07

Re: C++ Cout

Posted 02 September 2008 - 03:24 PM

That is C#.

edit: cout requires <iostream>

This post has been edited by KYA: 02 September 2008 - 03:25 PM

Was This Post Helpful? 0
  • +
  • -

#3 x-lil-monroe-x  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 16-March 08

Re: C++ Cout

Posted 03 September 2008 - 08:03 AM

thats why it says <iostream> on the default code in the book then :L thanks. ill try that.
Was This Post Helpful? 0
  • +
  • -

#4 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: C++ Cout

Posted 03 September 2008 - 08:25 AM

The code you have posted is actually C++.NET, whereas your book is obliviously the more industry standard ANSI compliant C++. they are two completely different languages, and compiled differently as well.
Was This Post Helpful? 0
  • +
  • -

#5 MorphiusFaydal  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 43
  • View blog
  • Posts: 1,376
  • Joined: 12-May 05

Re: C++ Cout

Posted 03 September 2008 - 03:28 PM

In Visual C++, when you create a new project, you want "Win32 console application" and turn off the "precompiled headers" option, if it's set. That'll make the code from the book work with the compiler.

This post has been edited by MorphiusFaydal: 03 September 2008 - 03:28 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1