Table of Contents

typedef static templates RTTI CPlusPlus.fr

C++ is a Programming language so called Object Oriented (OOP), sometimes refered as hybrid one

TODO

Learn

irc://irc.freenode.net/c++

keywords

REFERENCE

C++ [[Book]]s :

ebooks

http://mindview.net/Books/TICPP/ThinkingInCPP2e.html http://web.fromehtozed.ca/ThinkingInCPP/vol2/html/TicV2.html

CODES

* http://cpp.sourceforge.net/?style=dark

ToDo

Need samples on RTTI, STL, friendship, explicit , mutable etc

LIBS

MISC

SAMPLE CODE

// file://~/hello.cpp
#include <iostream>
#include <string>
using namespace std;
class Cls {
public:
void f(string arg="http://rzr.online.fr") { cout<<arg<<endl; }
};
// file://~/main.cpp
int main(int argc, char* argv[[]])  { Cls o; o.f(); }

Then compile :

make hello && ./hello
g++     hello.cpp   -o hello
http://rzr.online.fr

[[CPlusPlus]] : const keyword

int const value = 42;
// is equivalent (and prefered) to
const int value = 42;

think as const is a type modifyer

for a method that wont change the object :

class Foo { public void bar() const; };

Similar to final in Java

POINTERS & REFERENCES

/**
  * Vieille methode C : passage par addresse
  **/
int decompose(int nb,int* u,int* c,int* d)  {
int tu,tc,td; // variables temporaires pour un soucie de lisibilitee
tc=nb/100;
td=(nb/10-tc*10);
tu=(nb-tc*100-td*10);

}

/**
  * Local les valeurs retournees sont = a celle envoyées
  * donc inutile pour les fonctions , soit procedure
  **/
int decompose2(int nb,int u,int c,int d)  {
int tu,tc,td; // variables temporaires pour un soucie de lisibilitee
tc=nb/100;
td=(nb/10-tc*10);
tu=(nb-tc*100-td*10);
u = tu;
c = tc;
d = td;
}
/**
  * Bonne Methode C++
  * la reference est l'equivalent du pointeur en C
  **/
int decompose3( const int nb,int &u,int &c,int &d)  {
int tu,tc,td; // variables temporaires pour un soucie de lisibilitee
tc=nb/100;
td=(nb/10-tc*10);
tu=(nb-tc*100-td*10);
u = tu;
c = tc;
d = td;
}
int main() {
int u=0,c=0,d=0;
int n=423;
decompose(n,&u,&c,&d);
cout<,<"n="<,<n<,<endl;
cout<,<"dn = "<,<c<,<" "<,<d<,<" "<,<u<,<endl; // dn = 4 2 3
u=0,c=0,d=0;
decompose2(n,u,c,d);
cout<,<"dn = "<,<c<,<" "<,<d<,<" "<,<u<,<endl; // dn = 0 0 0
u=0,c=0,d=0;
decompose3(n,u,c,d);
cout<,<"dn = "<,<c<,<" "<,<d<,<" "<,<u<,<endl; // dn = 4 2 3
return 0;
}

pointer bug

 mywstring toStdWString() const;
 const wchar_t * ptr = myQString.toStdWString().c_str();
 Ooooo le zoli dangling pointer !

Allocator

http://www.informit.com/guides/content.asp?g=cplusplus&seqNum=40&rl=1

#include <new> // for size_t
class A  {
 public:
  A();
  ~A();
  static void* operator new (size_t size);
  static void operator delete (void *p);
};

DESTRUCTOR

LIBS

LEARN

MISC

MORE

@TaG: C Programming Java typedef Preprocessor GCC MSVC ptr ref TypeS TypE StD

8090_aoherrenberg_fun_fun_hell.jpg

8090_trail_had_20fun.jpg

8090_images_piercing.jpg