У меня есть проект в Visual Studio с оконными формами.
file1 myClass.cpp
Код: Выделить всё
#include "myClass.h"
string myClass::myFunction(std::string text) {
//function code
return var;
}
файл 2 myClass.h
Код: Выделить всё
#pragma once
#ifndef MYCLASS_H
#define MYCLASS_H
#include
#include
using namespace std;
class MyClass {
private:
string myFunction(string text);
};
файл 3 main.cpp
Код: Выделить всё
#include "myClass.h"
myClass myObject;
string data = myObject.myFunction(string text);
И это не работает.
Две ошибки:
Функция E0265 "myFunction::myClass" (объявлена в строке 18 файла "C:\Users................................\myClass.h") недоступна,
C2248 'myClass::myFunction': невозможно доступ к частному члену, объявленному в классе «myClass»
Подробнее здесь: https://stackoverflow.com/questions/798 ... class-in-c
Мобильная версия