Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.

Paste

Pasted as C++ by registered user raphael ( 3 years ago )
#ifndef TEST_H
#define TEST_H


class test {
public:
    int val;
    int* pVal;
    int k;
    int i;
    test(int x=40);          //Constructeur par transtypage et par defaut
    test(const test &other); //Constructeur par copie
    void toString();
};

#endif // TEST_H
//--------------------------------------------------------------------------------------------------------------------------------------------------------
#include "test.h"
#include <iostream>
using namespace std;

test::test(int x) : val(x), pVal(&val), k(x), i(k+1) {}

void test::toString() {
    cout << "val: " << val << ", *pVal: " << *pVal << ", pVal: " << pVal << endl;
}

test::test(const test &source){
    this->val = source.val;
    pVal = &val;
}

 

Revise this Paste

Your Name: Code Language: