1.

Solve : new user of c++?

Answer»

hi,iam new user of c++ so i want tips of how to tackle c++ problems.please give me tips.You are very vague.

Quote

Listed below are some common programming errors
1. Misuse of the Include Guard.
A common mistake is to use same symbol in multiple files for #ifndef.
2. Typo's : Using ">" for ">>" and "<" for "<<"
3. Trying to directly access the private variables in the main program.
4. Switch Statments without break.
5. Wrong usage of postfix and prefix operator (diff between i++ and ++i)
6. Undeclared and Unitialised Variables and functions.
7. ALWAYS USE MAKE FILE if you have more than one C++ program. The order of
compilations matters a lot too.
8. Trying to include "INCORRECT" header fuction.
9. Marking a member function as const in the class definition but not in the member function implementation.
10. Returning a value in a void function.
11. Confusing the name of an array with the contents of the first element.
12. Cstring array Errors - Arr[10] = Arr[0] to Arr[9]. Trying to access Arr[10] element.
13. Using "=" ( assignment operator ) INSTEAD of "= =" (comparison operators) scanf() without '&' and wrong format.(IN C)
14. Trying to divide a number by Zero.
15. Poor Loop Exiting comparisons will tend to either loop being not executed at all or goes to an infinite loop.
16. Not using STRING functions and TREATING the strings are integer . SAY trying to compare string by (string1= = string2) , rather than using strcmp command
17. CString not terminated by '\0'- Null character
18. Mismatched "{" or IF-ELSE statements or for that matter any looping statment.
19.Namespace errors
20. Forget }
21. Wrong number of }
22. Missing ;
23. Missing )
Quote from: taumang on February 18, 2011, 09:10:09 AM
hi,iam new user of c++ so i want tips of how to tackle c++ problems.please give me tips.
please post me a program and its algorithm so that i can understand what you are talking about.pretty basic stuff below, if you want to know more, ask what you want to know :p


//double forward slash allows for comments

#include //#include will include header files that will allow for functions that are within, iostream will be almost always used

using namespace std; //this will use standard namespace which will let you type cout instead of std::cout

int main(){ //this will define main function, function works within parenthesis

int number = 0; //sets variable number to 0 and declares i as an int

for (int i = 0; i < 3; i++){//loop 3 times
number++;//increment number by 1;
}//end loop

cout << number << endl; //output variable number (3) followed by a line break

return 0; //returns zero
}//end mainGoogle:
youtube C++ tutorial

Here is 'Hello World'
http://www.youtube.com/watch?v=vYHB0DUcfV0


Discussion

No Comment Found