Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef MACLASSE4_H
- #define MACLASSE4_H
- class Maclasse4
- {
- public:
- Maclasse4();
- ~Maclasse4();
- int m_entier;
- int *p = &m_entier;
- Maclasse4(int obj);
- Maclasse4(Maclasse4 &obj);
- int metprintp(int *ptr);
- void display();
- };
- #endif // MACLASSE4_H
- #include "maclasse4.h"
- #include <iostream>
- Maclasse4::Maclasse4()
- {
- }
- int Maclasse4::metprintp(int *ptr)
- {
- std::cout << *ptr << " print du pointeur" << std::endl;
- }
- Maclasse4::Maclasse4(int obj)
- {
- m_entier = obj;
- }
- Maclasse4::Maclasse4(Maclasse4 &obj)
- {
- m_entier = obj.m_entier;
- p = &obj.m_entier;
- }
- void Maclasse4::display()
- {
- std::cout<<std::endl<<"m_entier : " <<m_entier<<"\t"<<"*p : " <<*p<<"\t" << std::endl;
- }
- Maclasse4::~Maclasse4()
- {
- //std::cout << "je suis le destructeur" << std::endl;
- }
- #include <iostream>
- #include "maclasse4.h"
- using namespace std;
- int main()
- {
- Maclasse4 obj1, obj2;
- obj1.m_entier = 5;
- //obj1.metprintp(obj1.p);
- obj2 = obj1;
- obj1.display();
- obj2.display();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement