I came across this error:
main.cpp:22:34: error: ‘getTotalSystemMemory’ was not declared in this
scope
#include <unistd.h>
#include <cstdlib>
#include <stdio.h>
#include <iostream>
using namespace std;
/*
*
*/
int main(int argc, char** argv) {
cout << "Hello World! \n";
cout << getTotalSystemMemory();
return 0;
}
long getTotalSystemMemory()
{
long pages = sysconf(_SC_PHYS_PAGES);
long page_size = sysconf(_SC_PAGE_SIZE);
return pages * page_size;
}
I assumed the the method ‘getTotalSystemMemory’ is in scope since it is within the same class
You need to provide at least a declaration before you use the function: