[ create a new paste ] login | about

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

C, pasted on Oct 14:
#include<iostream>
#include<stdlib.h>
#include<conio.h>
using namespace std;
    class vector{
        private:
            int n;
            float *v;
        public:
        vector(int size);
        vector(vector &x);
        ~vector();
        void add();
        void display();
        int kiemtra(vector &x);
        friend vector operator +(vector &x,vector &y);
        void operator =(vector &x);
};
vector::vector(int size)
{
        int i;
        n=size;
        v=new float [n];
}
void vector::add()
{
    int i;
    for (i=0;i<n;i++){
        cout<<v[i];
            cin>>v[i];
        }
}
vector::vector(vector &x)
{
        int i;
        n=x.n;
        v=new float [n];
            for (i=0;i<n;i++)
                v[i]=x.v[i];
}
vector::~vector()
{
    delete v;
}
void vector::display()
{
        int i;
    for (i=0;i<n;i++)
        cout<<v[i];
}
void vector:: operator =(vector &x)
{
        int i;
            n=x.n;
            v=new float [n];
                for (i=0;i<n;i++)
                v[i]=x.v[i];
}
vector operator +(vector &x,vector &y)
{
        int i;
            vector z=x;
        for (i=0;i<x.n;i++)
        z.v[i]=x.v[i]+y.v[i];
            return z;
}
int vector::kiemtra(vector &y)
{
        if (n==y.n) return 1;
            return 0;
}

void main(){
    int n;
cout<<"Nhap so phan tu cua vector x:";
cin>>n;
vector x(n);
cout<<"Nhap vector a: \n";
 x.add();
cout<<"\nNhap so phan tu cua vector y: ";
cin>>n;
vector y(n);
cout<<"Nhap vector y: \n";
y.add();
cout<<"vector x: ";
x.display();
cout<<"\nvector : ";
y.display();
if(x.kiemtra(y)==1) {
    cout<<"\nvector tong la: ";
    (x+y).display();
    }
else cout<<"\n K cong  2 vector nay: ";
getch();
}


Output:
Line 18: error: iostream: No such file or directory
Line 17: error: conio.h: No such file or directory
Line 4: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'namespace'
Line 5: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'vector'
Line 19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
Line 25: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
Line 33: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
Line 41: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
Line 45: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
Line 51: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
Line 59: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'operator'
Line 67: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
In function 'main':
Line 75: error: 'cout' undeclared (first use in this function)
Line 75: error: (Each undeclared identifier is reported only once
Line 75: error: for each function it appears in.)
Line 76: error: 'cin' undeclared (first use in this function)
Line 77: error: 'vector' undeclared (first use in this function)
Line 77: error: expected ';' before 'x'
Line 79: error: 'x' undeclared (first use in this function)
Line 82: error: expected ';' before 'y'
Line 84: error: 'y' undeclared (first use in this function)
Line 73: warning: return type of 'main' is not 'int'


Create a new paste based on this one


Comments: