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?

Recommended Answers

All 5 Replies

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;
    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;
  L_5_s content;
  void f40918(){
    L_5 *last,*new;
    while (last->next)
    new = new L_5;
  void f37(){
    L_5 *tekuci=this->next;
    while (tekuci){
      cout << "-----------------" << endl;

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.