943,469 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 3922
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Aug 19th, 2004
1

New to C++, need help

Expand Post »
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)
Reputation Points: 11
Solved Threads: 0
Newbie Poster
RobinA is offline Offline
9 posts
since Aug 2004
Aug 19th, 2004
1

Re: New to C++, need help

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.
Reputation Points: 12
Solved Threads: 2
Posting Whiz
Ghost is offline Offline
352 posts
since Aug 2004
Aug 19th, 2004
1

Re: New to C++, need help

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
Reputation Points: 13
Solved Threads: 3
Posting Whiz
Sphyenx is offline Offline
366 posts
since Aug 2004
Aug 19th, 2004
0

Re: New to C++, need help

type after the include line :
using namespace std;

that is because cout defined in this namesoace that is all
Reputation Points: 11
Solved Threads: 0
Newbie Poster
stg110 is offline Offline
11 posts
since Aug 2004
Aug 19th, 2004
0

Re: New to C++, need help

stg110 thanks for the answer but i dont fully understand when i should use std; and :
Reputation Points: 11
Solved Threads: 0
Newbie Poster
RobinA is offline Offline
9 posts
since Aug 2004
Aug 20th, 2004
0

Re: New to C++, need help

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
Reputation Points: 11
Solved Threads: 0
Newbie Poster
stg110 is offline Offline
11 posts
since Aug 2004
Aug 20th, 2004
0

Re: New to C++, need help

ok i know why to use it but not when cant u write it in the code i wrote or something.?
Reputation Points: 11
Solved Threads: 0
Newbie Poster
RobinA is offline Offline
9 posts
since Aug 2004
Aug 20th, 2004
0

Re: New to C++, need help

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
Reputation Points: 11
Solved Threads: 0
Newbie Poster
stg110 is offline Offline
11 posts
since Aug 2004
Aug 20th, 2004
0

Re: New to C++, need help

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)?
Reputation Points: 11
Solved Threads: 0
Newbie Poster
RobinA is offline Offline
9 posts
since Aug 2004
Aug 20th, 2004
0

Re: New to C++, need help

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;
}
Reputation Points: 11
Solved Threads: 0
Newbie Poster
RobinA is offline Offline
9 posts
since Aug 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Sending and receiving ARP packets
Next Thread in C++ Forum Timeline: Is c # slower than c/c++





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC