EverEffects Backup Forum
Welcome To We Can't Program Forums, Please Log In To Access All Forums.

Enjoy Your Stay

- Staff
EverEffects Backup Forum
Welcome To We Can't Program Forums, Please Log In To Access All Forums.

Enjoy Your Stay

- Staff
EverEffects Backup Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

EverEffects Backup Forum

Designers World
 
HomePortalLatest imagesRegisterLog in



 C++ Quick Refrences Resize


Share | 
 

 C++ Quick Refrences

View previous topic View next topic Go down 
AuthorMessage
Fred
Staff
Staff
Fred

Posts : 33
Join date : 2010-05-27
Age : 31
Location : Oklahoma

C++ Quick Refrences _
PostSubject: C++ Quick Refrences   C++ Quick Refrences EmptyThu Jun 03, 2010 5:07 pm
Introduction
Today I will show you guys the basics of symbols use in C++, such as syntax and information for commonly used tasks, syntax, and more! Also this guide is good for beginners to experts, just to refresh there mind for experts. And for the beginners, you can use this references to make your own projects. And if you have questions about this please do so. I'll make myself specific as best as I can and post all of the commands needed. Here are the following I will be listing:

* Headers
* Namespace
* Data Types
* Comments
* Arithmetic Operators
* Relational Operators
* Logical Operators
* Pointers
* If/Else Statements
* For Loops
* While Loops
* Do While Loops
* Switch Statements
* Arrays
* I/O Operators
* File I/O
* File Mode Constants
* Function Prototypes
* Class Prototypes
* Structure Prototypes
* Accessing Data Structures

So lets get started...

C++ Command List

Include Headers:
#include <Headerfile_Text_here>

Common Headers:
iostream, fstream, math, cctype, string

Namespace:
using namespace std;

Data Types:
int, char, float, double, void, bool

Comments:
//Comment text
/* Multi-Line comment text*/

Arithmetic Operators:
+(Addition), -(Subtraction), *(Multiplication), /(Division), %(Modulus)

Relational Operators:
<(Less than), <=(Less than or Equal to), >(Greater than), >=(Greater than or Equal to), ==(Equal to), !=(Not equal to)

Logical Operators:
||(Logical OR), &&(Logical AND), !(Logical Not)

Pointers:
int *ptr //Define Pointer
ptr = &var //ptr set to address of var
var2 = *ptr //Set var2, to value of var1

If Else:
Code:
if(<condition>)
      { <statement1>; }
else
      { <statement2>; }

For Loop:
for(<initialize>;<condition>;<update>)
{ ; }

While Loop:
while (<condition>)
{ <statement>; }

Do-While Loop:
do{ <statement>; }
while (<constant>);

Switch Statement:
Code:
switch(<expression>)
{
case <constant1>
  <statement sequence 1>;
  break;
case <constant2>;
  <statement sequence 2>;
  break;

case<constantn+1>;
  <statement sequence n+1;
  break;
[default:
  <statement sequence n>;
    break;]
}

Arrays:
//New 5 element array
int my Array[5];
//Array index starts at 0
//Access 3rd element
myArray[2]=var;

I/O Operators:
>> //Input Operator
<< //Output Operator
cin >> var1, var2, var3;
cout << "TEXT HERE" << var1 << endl;
cin.get(char*buffer, streamsize num, char delim);

File I/O:
Code:
fstream file;
file.open ("filename",<file mode constant);
    //Reads and writes like cin and cout
          file >> var;
          file << "TEXT HERE"<< var << endl;
    //Read Entire Line
        getline (file,line);
    //Reading Writing Binary Data
        file.read(memory_block, size);
        file.write(memory_block, size);
file.close();

File Mode Constants:
ios::in //Open file for reading
ios:ut //Opens file for writing
ios::ate //Seeks the EOF.I/O operations can occur anywhere
ios::app //Causes output to be appended at EOF
ios::trunc //Destroys the previous contents
ios::nocreate //Causes open() to fail if file doesn't already exist
ios::noreplace //Causes open() to fail if file already exist

Function Prototype:
<return_data_type> <function_name>(parameter list)
{ body of the function }

Class Prototype:
Code:
class <class_name>
{
public:
  //method_prototypes
protected:
  //method_prototypes
private:
  //method_prototypes
 //data_attributes
};

Structure Prototype:
struct <structure_name> {
member_type1 member_name1;
member_type2 member_name2;
} <object_name> ;

Accessing Data Structures:
//Access member variable from Struct/Class
myStruct.membervar1 = var;
//Call class method
myClass.method(args);
//Pointer to Struct/Class
myStructType *ptr;
ptr = &myStruct;
ptr->membervar1 = var;

Thanks for reading and I hope you learn something
Back to top Go down
http://wcpforums.friendhood.net
 

C++ Quick Refrences

View previous topic View next topic Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
EverEffects Backup Forum :: C/C++/C#/VisualC++-
Jump to:  


   [Valid RSS]





Free forum | ©phpBB | Free forum support | Report an abuse | Forumotion.com