Skip to content

Instantly share code, notes, and snippets.

@ChaosEngine
Created February 5, 2015 22:32
Show Gist options
  • Save ChaosEngine/933765312d11f7dcd029 to your computer and use it in GitHub Desktop.
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]
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)
#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;
}
#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
#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;
}
#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