I think I have forgotten something

2008-09-02 22:54:00 |

When I review the C++ code which constitutes our production, I realized that, I have forgotten a lot of skill in C++, for example, checks the following code snippet:
#include <string>
#include <iostream>
int main()
{
 string name;
 cout<<”Plz input the list of customers ”;
 while(cin >> name)
{
 cout<<”Name: ”<<name;
}
}
The question is, after the program has been started successfully, follow the prompt, if we input “A B C” in one line, what should we got in the consol?
The correct answer is:
 Name: A
 Name: B
 Name: C
My answer is “Name: A B C”, I confused the class “cin” with the standard input devices which in C style.

I also confused with the style of our code, we use the STL as the foundation library, and use standard C++, but I found that there is a good deal of code using the old C style, such as “sprint(..)” , ”printf”, “char *”. I am not meaning that C style is worse and STD is better, I just want to say, if you are using a new style, you should keep on it, otherwise, it would look like a fright.

I got one tip: you can define the preprocessor in the command line to compile the program, for example, you code is:
#ifdef TESTB
  Cout<<”This line is inside testb”;
#endif
You should use compile-command like this: “cc –DTESTB some_src_files”

To be honest, I am missing the days with “public class”.

Comments (1) -

Lacey Mergist :

Many people could have heard about P90X or seen the infomercials on the workout program but might not be completely familiar with it. P90X is a total body fitness program that claims to get an individual ripped in only 90 days. This includes six pack abs. It has 12 distinct workouts which are done a normal scheduled basis. Not just will the workouts assist you to to build far more muscle, which truly burns calories at a faster rate, but they are going to definitely get you into the fat burning zone.

Add comment




biuquote
  • Comment
  • Preview
Loading