Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <string>
- #include <iostream>
- using namespace std;
- #include "lib.h"
- Software::Software() {
- this->name = "unknown";
- this->type = "unknown";
- this->author = "unknown";
- }
- Software::Software(string name, string type, string author) {
- this->name = name;
- this->type = type;
- this->author = author;
- }
- string Software::get(int var) {
- if (var >= 0 && var <= 2) {
- if (var)
- return (var == 1) ? this->type : this->author;
- else
- return this->name;
- }
- else
- return "";
- }
- void Software::set(int var, string value) {
- if (var >= 0 && var <= 2) {
- if (var == 0)
- this->name = value;
- else if (var == 1)
- this->type = value;
- else
- this->author = value;
- }
- }
- void Software::print() {
- printf("Software:\nname: %s\ntype: %s\nauthor: %s\n", this->name.c_str(), this->type.c_str(), this->author.c_str());
- }
- int main(void) {
- Software a("name", "type", "author");
- a.print();
- printf("\n");
- a.set(sw_name, "---");
- a.print();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement