Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <cstring>
- using namespace std;
- class Article{
- private:
- char title[100];
- char author[50];
- char *content;
- bool publish;
- public:
- Article(char *title="", char *author="", char *content="", bool publish=0){
- strcpy(this->title, title);
- strcpy(this->author, author);
- this->content=new char[strlen(content)+1];
- strcpy(this->content, content);
- this->publish=publish;
- }
- void show(){
- cout<<title<<endl;
- cout<<author<<endl;
- cout<<content<endl;
- }
- ~Article(){
- delete [] content;
- }
- };
- class Newspaper{
- private:
- char name[100];
- Article **p;
- int articles;
- Article first;
- public:
- Newspaper(char *name="", Article **p=Article(), int articles=0, Article first=Article()){
- strcpy(this->name, name);
- }
- };
- int main() {
- char title[100], author[50], content[100];
- int n;
- cin >> n;
- char name[100];
- cin.getline(name, 100);
- cin.getline(name, 100);
- Article first("VAZNO","OOP","Vezba:OOP",true);
- Newspaper v(name,first);
- Article **s = new Article*[n];
- for(int i = 0; i < n; ++i) {
- cin.getline(title, 100);
- cin.getline(author, 50);
- cin.getline(content, 100);
- v.addArticle(Article(title, author, content, true)); //se koristi copy konstruktor
- }
- v.showFirst();
- v.showLongest();
- cout << v.totalofauthor(author) << endl;
- for(int i = 0; i < n; ++i) {
- delete s[i];
- }
- delete [] s;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement