• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

New to c++ and need help.

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

creepy

Member
Joined
Feb 15, 2003
Location
tn
I just got into learning c++ two days ago and yesterday I purchased the book "learn c++ in 21 days". I got passed day one no problem. Read day 2 (today) and understood it pretty well. Now comes my problem. I am using the Dev Bloodshed c++ editor + compiler. When I try to compile the following code (listed below this paragraph). I get the following error(s).

UNIT: 9 h:\docume~1\ajm~1.aar\desktop\chapter2.cpp
MESSAGE: `::end1' undeclared (first use here)"

AND

UNIT: 11 h:\docume~1\ajm~1.aar\desktop\chapter2.cpp

MESSAGE: confused by earlier errors, bailing out



What do these errors mean and what am I doing wrong. According to my knowledge im copying this DIRECTLY from the book as it says I should. Also does anyone have some tips on learning c++. Thanks. (below is the code im trying to compile)

// Listing 2.2 using std::cout
#include <iostream>
int main()
{
std::cout << "Hello there.\n";
std::cout << "Here is 5: " << 5 << "\n";
std::cout << "The manipulator std::end1 ";
std::cout << "writes a new line to the screen.";
std::cout << std::end1;
std::cout << "here is a very big number:\t" << 70000;
std::cout << std::end1;
std::cout << "Here is the sum of 8 and 5:\t" << (8+5) << end;
std::cout << 8+5 << std::end1;
std::cout << "Here's a fraction:\t\t";
std::cout << (float) 5/8 << std::end1;
std::cout << "And a very very big number:\t";
std::cout << (double) 7000 * 7000 << std::end1;
std::cout << "Dont forget to replace Jesse Liberty";
std::cout << "With your name...\n";
std::cout << "Aaron McBride is a C++ programmer!\n";
return 0;
}
 
I am going to assume you misread the font in the book you are using, and that you didn't mistype endl in your sample code, but that is the problem. It's endl with a lower case L; short for end line.

Edit:
Also, this line:
std::cout << "The manipulator std::end1 ";
should be
std::cout << "The manipulator" << std::endl;

Since you are learning, and probably don't know much about namespaces and scope resolution, you can also save yourself a lot of typing by putting the line

using namespace std;

after your include statements (#include <iostream>), and then you won't have to type std:: all the time.
 
TYYYYY SO MUCH for the help. As you said...I misread the font in the book looks like a 1 but guess its a "L"...Its amazing how you can spend a whole day tryin to figure something out.
 
Back