Hi everyone!
So I have this code to modify.
I need to write a code inside the int main field, that would cause 37 launches of the constructor called M_48().
I have no idea how to solve this. Any ideas?
Hi everyone!
So I have this code to modify.
I need to write a code inside the int main field, that would cause 37 launches of the constructor called M_48().
I have no idea how to solve this. Any ideas?
If I understand your question I don't see why you would want something like that. But a constructor is called when an object is created. So create a loop that iterates 37 times and create an M_48 object every iteration by calling the default constructor. (M_48 value;
)
Seems simple enough:
#include <iostream>
class M_48 {
static int instances;
public:
M_48() { std::cout << ++instances << ": Foo!\n"; }
};
int M_48::instances = 0;
// This is the part you really want
int main()
{
M_48 foo[37];
}
This is how the code looks like:
class L_5{
L_5 *next;
public:
L_5_s content;
L_5(){
next=NULL;
};
void f40918(){
L_5 *last,*new;
last=this;
while (last->next)
last=last->next;
new = new L_5;
last->next=new;
new->content.input();
};
void f37(){
L_5 *tekuci=this->next;
while (tekuci){
cout << "-----------------" << endl;
tekuci->content.print();
tekuci=tekuci->next;
}
};
};//L_5
Oh yes, one more thing.
I would like to modify this class L_5, that object from class L_5_s is included by reference (instead by value).
Is it posible?
This is how the code looks like:
That doesn't change my answer. But your code is completely broken. Perhaps if you used names that weren't completely meaningless, I'd be able to suggest ways to change the code so that it both compiles and does what you want.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.