Created
February 5, 2015 22:32
-
-
Save ChaosEngine/933765312d11f7dcd029 to your computer and use it in GitHub Desktop.
Person.cpp:6:1: warning: ‘Person::name’ is initialized with itself [-Winit-self]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CC=g++ | |
CCFLAGS=-Wall | |
LDFLAGS=-Wall | |
SOURCES=$(wildcard *.cpp) | |
OBJECTS=$(SOURCES:.c=.o) | |
TARGET=Ludziki | |
all: $(TARGET) | |
$(TARGET): $(OBJECTS) | |
$(CC) $(LDFLAGS) -o $@ $^ | |
%.o: %.c %.h | |
$(CC) $(CCFLAGS) -c $< | |
%.o: %.c %.h | |
$(CC) $(CCFLAGS) -c $< | |
clean: | |
rm -f *.o $(TARGET) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include "Person.h" | |
using namespace std; | |
Person::Person(const char* nameL, const char* surnameL) | |
: name(name), surname(surname) | |
{ | |
} | |
void Person::ToString() | |
{ | |
cout << "Name = " << name << ", Surname = " << surname << endl; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _PERSON_H_ | |
#define _PERSON_H_ | |
#include <iostream> | |
using namespace std; | |
class Person | |
{ | |
private: | |
const char* name; | |
const char* surname; | |
public: | |
Person(const char* nameL, const char* surnameL); | |
virtual ~Person() | |
{ | |
} | |
virtual void ToString(); | |
}; | |
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include "Person.h" | |
#include "Student.h" | |
using namespace std; | |
Student::Student(const char* name, const char* surname) | |
: Person(name, surname) | |
{ | |
} | |
int main(int argc, char** argv) | |
{ | |
Student* s = new Student("Czarli", "Cykor"); | |
s->ToString(); | |
delete s; | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _STUDENT_H_ | |
#define _STUDENT_H_ | |
#include <iostream> | |
using namespace std; | |
class Student : public Person | |
{ | |
private: | |
int year; | |
public: | |
Student(const char* name, const char* surname); | |
virtual ~Student() | |
{ | |
} | |
}; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment