
请问这个用C++怎么写呢?定义类之后那个get(),set()函数怎么写呢?
class News {
public:
News(int newsid, std::string newstitle, std::string newscontent, std::string newsauthor, bool isavailable)
{
this->newsid = newsid;
this->newstitle = newstitle;
this->newscontent = newscontent;
this->newsauthor = newsauthor;
this->isavailable = isavailable;
}
void set_newsid(int newsid)
{
this->newsid = newsid;
}
int get_newsid()
{
return newsid;
}
void set_newstitle(std::string newstitle)
{
this->newstitle = newstitle;
}
std::string get_newstitle()
{
return newstitle;
}
void set_newscontent(std::string newscontent)
{
this->newscontent = newscontent;
}
std::string get_newscontent()
{
return newscontent;
}
void set_newsauthor(int newsid)
{
this->newsauthor = newsauthor;
}
std::string get_newsauthor()
{
return newsauthor;
}
void set_isavailable(bool isavailable)
{
this->isavailable = isavailable;
}
bool get_isavailable()
{
return isavailable;
}
private:
int newsid;
std::string newstitle;
std::string newscontent;
std::string newsauthor;
bool isavailable;
};