Я полный новичок в C ++, и у меня возникают проблемы с объявлением моих функций в файле header.h
, определенным в header.cpp
и вызванным в main.cpp
.Я искал решения, но ничего, что я делаю, похоже, не работает.Буду признателен за информацию о том, как я могу решить эти проблемы.
Вот мой код:
main.cpp
#include <iostream>
#include "DLinkedList.h"
int main() {
getInfo(); //Running my function getInfo
}
DLinkedList.h
#ifndef DLINKEDLIST_H
#define DLINKEDLIST_H
class Node
{
private:
int info;
public:
Node* prev;
Node* next;
int getInfo(); //Declaring my function getInfo
void setInfo(int value);
};
#endif
DLinkedList.cpp
#include <iostream>
#include "DLinkedList.h"
int getInfo() { //Defining my function getInfo
int answer;
std::cout << "Input the integer you want to store in the node: ";
std::cin >> answer;
return answer;
}
и сообщение об ошибке:
exit status 1
main.cpp: In function 'int main()':
main.cpp:6:3: error: 'getInfo' was not declared in this scope
getInfo();
^~~~~~~