New to C++, need help

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2004
Posts: 9
Reputation: RobinA is an unknown quantity at this point 
Solved Threads: 0
RobinA RobinA is offline Offline
Newbie Poster

New to C++, need help

 
1
  #1
Aug 19th, 2004
hi im new to c++ (started today) and im reading a book about c++ (called C++ Programming A)

Well i started to read and learned the first code and wrote it in Microsoft Visual C++ and i get a error (error C2065: 'cout' : undeclared identifier) i dont know why cause ive written exactly what it says in the book, and can post the code to

# include <iostream>
int main ()
{
int tal1=5, tal2=11, produkt;
produkt=tal1*tal2;
cout << "Produkten är" << produkt;
}


one more question what am i supposed to write in () after int main.?

Thanks in forehand ( and by the way a great forum)
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 350
Reputation: Ghost is an unknown quantity at this point 
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Re: New to C++, need help

 
1
  #2
Aug 19th, 2004
Try declaring product on a new line. For your second question, nothing goes in the () after main. You only use them when working in functions and passing variables.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 366
Reputation: Sphyenx is an unknown quantity at this point 
Solved Threads: 2
Sphyenx's Avatar
Sphyenx Sphyenx is offline Offline
Posting Whiz

Re: New to C++, need help

 
1
  #3
Aug 19th, 2004
ya im gona start c++ soon, cause every one tells me to, but ill promise you 1 thing. I know nothing. Im starting from scratch, but what should i already know. Html, perl ect. cause i dont know either. I was recomendd to learn perl first, but then c++ from another guy, then Qbasic from another. IM SO CONFUSED!. lol.

whats C/c++ for
Whats Qbasic or basic for
whats Perl for
whats open gl for
whats DirectX for
is this a dream



We should all respect Dani, shes the admin and she does a damn good job!. Not to forget the rest of the mod's =)


http://img.photobucket.com/albums/v5...46/Sphyenx.jpg
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 11
Reputation: stg110 is an unknown quantity at this point 
Solved Threads: 0
stg110 stg110 is offline Offline
Newbie Poster

Re: New to C++, need help

 
0
  #4
Aug 19th, 2004
type after the include line :
using namespace std;

that is because cout defined in this namesoace that is all
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 9
Reputation: RobinA is an unknown quantity at this point 
Solved Threads: 0
RobinA RobinA is offline Offline
Newbie Poster

Re: New to C++, need help

 
0
  #5
Aug 19th, 2004
stg110 thanks for the answer but i dont fully understand when i should use std; and :
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 11
Reputation: stg110 is an unknown quantity at this point 
Solved Threads: 0
stg110 stg110 is offline Offline
Newbie Poster

Re: New to C++, need help

 
0
  #6
Aug 20th, 2004
alwayes when use c++ u must add this line to make use of the new functionalty in c++ u need not add this line if u will write a normal c code
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 9
Reputation: RobinA is an unknown quantity at this point 
Solved Threads: 0
RobinA RobinA is offline Offline
Newbie Poster

Re: New to C++, need help

 
0
  #7
Aug 20th, 2004
ok i know why to use it but not when cant u write it in the code i wrote or something.?
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 11
Reputation: stg110 is an unknown quantity at this point 
Solved Threads: 0
stg110 stg110 is offline Offline
Newbie Poster

Re: New to C++, need help

 
0
  #8
Aug 20th, 2004
as a role when u write a c++ code type it after finishing the include lines
in other words u alwayes u can(or u must) type it
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 9
Reputation: RobinA is an unknown quantity at this point 
Solved Threads: 0
RobinA RobinA is offline Offline
Newbie Poster

Re: New to C++, need help

 
0
  #9
Aug 20th, 2004
i wrote the thing after but it still doesnt work or is it wrong again?


# include <iostream>
int main()
{
int tal1, tal2, produkt;
tal1=5;
tal2=11;
produkt=tal1*tal2;
cout <<"Produkten är" << produkt;
using namespace std;
}
(or should i write "using namespace std;" here)?
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 9
Reputation: RobinA is an unknown quantity at this point 
Solved Threads: 0
RobinA RobinA is offline Offline
Newbie Poster

Re: New to C++, need help

 
0
  #10
Aug 20th, 2004
ok i fixed it now but got one more question (heres the final code i used) when i click run the program it opens but it closes itself in about 0.01 sec after it have opened. whats the wrong now with the code, and i dont get any errors when compiling.

# include <iostream>
int main()
{
using namespace std;
int tal1, tal2, produkt;
tal1=5;
tal2=11;
produkt=tal1*tal2;
cout <<"Produkten är" << produkt;
}
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC