Questions from a "dummy" - page 168

 

Good afternoon!

Here's the thing (C++):

cout: CopyConstr_Class1

Why doesn't the CopyConstr_Class2 constructor with reference work? I.e. there are no errors and everything compiles ok but it doesn't work.

If it's not a problem, I ask those of you who have C++ not in VS2008 form to compile and try.

Sorry my stupidity, I wrote wrong one, ABOUT!!!!!!!!!!!!!!!!!!!

 

Hello again!

I'm asking for some advice. Is it possible to implement such a thing in C++:

class Parent
{
public:
   className *var;    // className это моя придумка
   clasName *Get();
};

class Derived : public Parent
{

};

main()
{
   Derived class;
   Derived *pClass;
   pClass = class.Get();
   return;
}
The idea is to have a type (className), which is instantiated in each specific descendant class, take the type of the class it contains. I don't want to put static_casts everywhere.
 

Hello.

Here's what I would like to find out:

Class MyClass
{
   MyClass() {}
   void fn();
};

void MyClass::fn()
{
   int var1, var2, var3;
   var3 = var1 + var2;
   return;
}

There is a class that has a function (any function, the important thing is that it takes some amount of pmayati).

MyClass array[1000];
We have created multiple instances of the class. Question: Each instance of MyClass class will contain its own function fn() (a set of commands) or all instances of the class will not duplicate commands that contain the function?
 
220Volt:

Hello.

Here's what I would like to find out:

There is a class that has a function (any function, the important thing is that it takes some space).

We have created multiple instances of the class. Question: will each instance of MyClass class contain its own function fn() (a set of commands) or will all instances of the class not duplicate commands that contain the function?
Exactly.
 
220Volt:

Hello.

Here's what I would like to find out:

There is a class that has a function (any function, the important thing is that it takes some space).

Create multiple instances of the class. Question: Each instance of MyClass class will contain its own function fn() (a set of commands) or all instances of the class will not duplicate commands which contain the function?

There will only be one function fn() for all instances of the class.

The class instances occupy memory only with their data.

 
stringo:

There will only be one fn() for all instances of the class.

The class instances occupy memory only with their data.

Careful Slava with abstractions, you will screw up the guy's brains, he will drill them into you later.
 
Thank you for your answers.
 
Urain:
I was about to write a long answer, but I decided that a long answer might be a good way to get your head screwed on.

I would be happy to answer any questions here, if they arise.

I was about to write a long answer, but I decided that a long answer would be the most likely to screw up the guy's brain. It's better to keep it short: question and answer.

 
stringo:

There will only be one fn() for all instances of the class.

The class instances occupy memory only with their data.

+ pointer to virtual function table. It's not good to cheat little people... ;-)
Документация по MQL5: Основы языка / Объектно-ориентированное программирование / Виртуальные функции
Документация по MQL5: Основы языка / Объектно-ориентированное программирование / Виртуальные функции
  • www.mql5.com
Основы языка / Объектно-ориентированное программирование / Виртуальные функции - Документация по MQL5
 

how to show the real name of an input variable ? not the comment next to it ?

neither ///

nor /**/

everything comes out instead of the real name

Reason: