Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 months ago
767 B
1
Indexable
Never
// Online C++ compiler to run C++ program online
#include <iostream>
#include <string>
using namespace std;
class example{
public:
    example(const string& iname, int s = 5)
    :itemname(iname)
    {
        //itemname = iname;
        int size =s;
        data = new int[size];
        count++;
    }
    example(const example& src)
    :itemname(src.itemname)
    {
        //itemname = src.itemname;
        data = new int[5];
        count++;
    }
    string getstr(){
        return itemname;
    }
private:
    const string itemname;
    int size;
    int* data;
    static int count;
};
int example::count = 0;

int main() {
   
    example ex1("abc");
    cout << ex1.getstr();
    
    //example ex2 = ex1;
    //cout << ex2.getstr();
    
    return 0;
}
Leave a Comment