User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 456,611 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,453 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 2714 | Replies: 14
Reply
Join Date: Aug 2004
Posts: 9
Reputation: RobinA is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
RobinA RobinA is offline Offline
Newbie Poster

New to C++, need help

  #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)
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2004
Location: Los Angeles
Posts: 345
Reputation: Ghost is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Re: New to C++, need help

  #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.
CRD
Join the CRD forums! If you're one of the first 4 people to post in a topic, you get FREE web hosting with:
Apache WWW Host
Unlimited (within reason) storage
Unlimited (within reason) bandwith
PHP
mySQL
FTP
Unlimited Subdomains Hosted
Unlimited Domains Hosted

ALL FREE!!

Click here to visit
Reply With Quote  
Join Date: Aug 2004
Location: Mass
Posts: 366
Reputation: Sphyenx is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 2
Sphyenx's Avatar
Sphyenx Sphyenx is offline Offline
Posting Whiz

Re: New to C++, need help

  #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  
Join Date: Aug 2004
Posts: 11
Reputation: stg110 is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 0
stg110 stg110 is offline Offline
Newbie Poster

Re: New to C++, need help

  #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  
Join Date: Aug 2004
Posts: 9
Reputation: RobinA is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
RobinA RobinA is offline Offline
Newbie Poster

Re: New to C++, need help

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

Re: New to C++, need help

  #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  
Join Date: Aug 2004
Posts: 9
Reputation: RobinA is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
RobinA RobinA is offline Offline
Newbie Poster

Re: New to C++, need help

  #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  
Join Date: Aug 2004
Posts: 11
Reputation: stg110 is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 0
stg110 stg110 is offline Offline
Newbie Poster

Re: New to C++, need help

  #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  
Join Date: Aug 2004
Posts: 9
Reputation: RobinA is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
RobinA RobinA is offline Offline
Newbie Poster

Re: New to C++, need help

  #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  
Join Date: Aug 2004
Posts: 9
Reputation: RobinA is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
RobinA RobinA is offline Offline
Newbie Poster

Re: New to C++, need help

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the C++ Forum

All times are GMT -4. The time now is 7:21 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC