abstract_classes.h:

#pragma once #include "class_word.h" using namespace System; ref class notion abstract { protected: String ^ _language; String ^ _inscription; String ^ _meaning; int _id; public: notion(String ^ lng, String ^ inscr, String ^ mnng) : _language(lng), _inscription(inscr), _meaning(mnng) { } virtual int print() abstract; }; //--------------------------------------------------------------------- ref class vocabulary { private: array<notion ^> ^ntn_array; public: vocabulary(); void set_array(String ^file_path, String ^lng); }; inline vocabulary::vocabulary() { ntn_array = nullptr; } inline void vocabulary::set_array(String ^file_path, String ^lng) { array<String ^> ^whole = IO::File::ReadAllLines(file_path); ntn_array = gcnew array<notion ^>(whole->Length); // allocate memory for(int i = 0; i < whole->Length; ++i) { array<String ^> ^current = whole[i]->Split('#'); // THE ERROR HERE BELOW ntn_array[i] = gcnew word(lng, current[0], current[2], current[3]); } } 

class_word.h

 #pragma once #include "abstract_classes.h" ref class word : public notion { String ^example; static int counter = 0; public: word():notion("","","") { }; word(String ^lng, String ^inscr, String ^mnng, String ^expl) : notion(lng, inscr, mnng), example(expl) { _id = ++counter; } virtual int print() override { return 0; } }; 

main.cpp

 #include "abstrace_classes.h" int main() { return 0; } 

Problem:

From the file, the data is loaded line by line into an array of type String ^ . Elementally, each line is divided into substrings and put into the current array of the String ^ type too String ^ Class vocabulary - container for abstract notion , from which the word is inherited. The point is that even instantiation does not reach the main.cpp file. In the set_array method of the vocabulary class, it gives an error:

A value of type word ^ cannot be assigned to entities of type notion ^

And I want to assign a reference to a child in the pointer to an abstract class. Maybe it's in the descriptors? How to use the link and not the descriptor?

    1 answer 1

    All declarations and class implementation must be placed in one file. It compiles without errors. It seems that they do not see each other in different files.