string - Dev C++ keeps crashing when I run this code. I cannot figure out why -


i not know whats going on. program seemed work fine on visual studio. maybe got wrong , cant spot it.. please me out one.

#include <iostream> #include<string> #include<cstdlib>  using namespace std; class aokiji { private:     string name1;     string name2; public:     string setname(string x)     {         name1=x;     }     string getname()     {         return name1;     } };  int main() {     aokiji grapes;     grapes.setname("i got it!");     cout<< grapes.getname()<< endl;     system("pause"); } 

your setname() function doesn't return anything, it's supposed return std::string. need return value, or make setname() function void (which should be)


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -