[ create a new paste ] login | about

Link: http://codepad.org/AgeVdQh8    [ raw code | output | fork ]

C++, pasted on Sep 14:
#include <iostream>
#include <vector>

struct no
{
    short d;
}
struct my
{
int a;
int d;
struct no n;
my(int i)
{a = d = i;
n.d = i;
}
my& operator=(const my& m)
{ a = m.a; d = m.d;  n.d = i; return *this; }
};

int main()
{
    vector<my> v;
    my m1(1),m2(2);
    v.push_back(m1);
    v.push_back(m2);
    
    vector<my>::iterator it;
    for( it = v.begin(); it < v.end(); it++)
    {
        my m = *it;
        std::cout<< m.a << endl; 
    }
    return 0; 

}


Output:
1
2
3
t.cpp: In member function 'my& my::operator=(const my&)':
Line 18: error: 'i' was not declared in this scope
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: