Hi Team
I need help i am using c++ libraries and trying to compile my program somehow i am experience the below errors
In file included from prog.cc:208:0:
/opt/wandbox/gcc-7.2.0/include/c++/7.2.0/ctime: In member function 'void unit_test::interval_map::assign(const K&, const K&, const V&)':
/opt/wandbox/gcc-7.2.0/include/c++/7.2.0/ctime:58:1: error: 'namespace' definition is not allowed here
namespace std
^~~~~~~~~
prog.cc:210:1: error: a template declaration cannot appear at block scope
template
^~~~~~~~
prog.cc:262:1: error: a function-definition is not allowed here before '{' token
{
// code
#include
Rajkiran SwainPosted Apr 23, 2023, 4:10 PM
To fix this error, you should move the template declaration outside the class definition and place it before the class definition. In other words, replace the template declaration in line 210 with the following:
template class interval_map { // ... };