cpp notes

cpp notes - vector a; vector b; a+=b; //will modify a...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
//array of character arrays char ** names; char * temp; names = new char * [10] char*[0] = new char[10] // ****** int main() { char* vals; vals = new char[5]; *(vals +1) = 'm'; foo(vals); } void foo(char * temp) { temp[0]= 's'; } //******** operators _________ 1. member functions - a OP b 2. global friend functions class vector { public: vector operator+(vectorb); vector operator+(int); vector operator*(int); private: int size, capacity; int * data; }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
*******************
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: vector a; vector b; a+=b; //will modify a vector & vector::operator=(const vector& rhs) { for(int i=0; i < rhs.size; i++){ this --> insert(rhs.data[i]); } return *this; } //won't modify a or b vector a,b,x; x = a +b; vector vector:: operator+(const vector&rhs) { vector temp = *this; temp += rhs; return temp; } If return in method header is something & then return type should be * something...
View Full Document

This note was uploaded on 11/11/2009 for the course CSE 2341-H taught by Professor Markfontenot during the Spring '09 term at SMU.

Page1 / 2

cpp notes - vector a; vector b; a+=b; //will modify a...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online