Q:

C++ code builds in CodeBlocks but not in Visual Studio 2015

I was given sample code in a C++ course I am taking.  I can get it to build in CodeBlocks but not in Visual Studio 2015.  In Visual Studio the main line "rename test3;" raises an error looking for a semicolon and the variable declaration in that line, "rename", is not highlighted in the default green for a type as it should be.  Same for the next line.  Therefore test3 and test4 come up as undefined.  If I remove "#include <iostream>" "rename" turns to green in lines 33 and 34 but then the std include become undefined.  Implementing "using namespace std" doesn't help either.  I am attempting to get rid of "using namespace std" as it is not good coding practice from what I understand around here.  I am missing a VS setting I think.
//#include <iostream>  // original first two line
//using namespace std; //
#include <iostream>  
#include <cstring>  // I added this include
using std::cin;     // I added the following using lines
using std::cout;
using std::endl;

class feature {  // this class has a specific feature

private:
    char data[16];
public:
    feature() { strcpy(data, "default"); }
    feature(char * in) { strcpy(data, in); }  // error checks needed

    void set(char * in) { strcpy(data, in); }
    void out() { cout << data << endl; }

};

class rename : private feature {
public:
    void reset(char * in) { set(in); }
    void print() { out(); }
    rename() : feature() {}
    rename(char * in) : feature(in) {}
};

int main() {
    feature test1;
    feature test2("test2 data");

    rename test3;
    rename test4("test4 data");

    test1.out();
    test2.out();
    test3.print();
    test4.print();
}

The results should be:
default
test2 data
default
test4 data
default
test4 data

If I change back to the original first two lines the code does not work.  If I rename "rename" to "rename1" then the code works.
#include <iostream>
using namespace std;

class feature {  // this class has a specific feature

private:
    char data[16];
public:
    feature() { strcpy(data, "default"); }
    feature(char * in) { strcpy(data, in); }  // error checks needed

    void set(char * in) { strcpy(data, in); }
    void out() { cout << data << endl; }

};

class rename1 : private feature {
public:
    void reset(char * in) { set(in); }
    void print() { out(); }
    rename1() : feature() {}
    rename1(char * in) : feature(in) {}
};

int main() {
    feature test1;
    feature test2("test2 data");

    rename1 test3;
    rename1 test4("test4 data");

    test1.out();
    test2.out();
    test3.print();
    test4.print();
}

A:

rename is a function that gets included by the header <cstring> in Visual Studio, which causes a conflict with the name of your class. You therefore need to change the name of your derived class. Visual Studio will probably also require you to change strcpy to strcpy_s (it may either give a Warning or Error otherwise).
Ideally you should avoid using C compatibility headers in new code you write (unless you absolutely need them), e.g.: in your example you should stick to std::string instead of char*

