cs Sept 23, 2014
Ch 8 : C++ overview
Ch 5 : exce topms
By now you should have read ch3 to ch 8
except 6 and 7
scope : limit to be as local as possible so identifiers can be reused and maintained more asily, debug more easily.
#include <iostream>
class A
{
public :
int c; // class scope
};
int x ; // global scope file
int main ()
{
int y; // local scope
A a1;
for (int i =0; i <N ; i++)
cout << i; // statement scope
std::cout << a1.c; (first is namespace scope and teh second is clas scope
}
int f(int a) // local scope (function) (block)
{
int b;
}
default x, 0 as it is a global variable but not y as it is a local variable.
What is the default initialization of objects of type A. use default constructor
Pg 266
Pg 260
while (double d; cin >> d)
Interface : declaration
.h
-- main application will use these by including thing include . h files
Implementation : definition
.cpp will also include the .h files to implement the interface.
vector<string> v; //initialized to empty
cannot do initialization in the class, definiing a type when we do the following
class A
{
public :
int c; / can't initialize
}
only in the default constructor.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home