recreation of ex 02
This commit is contained in:
parent
cfee0e2ec4
commit
ea247970e4
@ -1,25 +1,25 @@
|
|||||||
CXX = c++
|
CXX = c++
|
||||||
CXXFLAGS = -std=c++98 -Wall -Wextra -Werror -g -O0
|
CPPFLAGS = -std=c++98 -Wall -Wextra -Werror -g
|
||||||
SRCDIR = src
|
SRCDIR = src
|
||||||
OBJDIR = obj
|
OBJDIR = obj
|
||||||
BINDIR = bin
|
NAME = ex00
|
||||||
EXECUTABLE = ref_vs_ptr
|
|
||||||
|
|
||||||
SRCS = $(wildcard $(SRCDIR)/*.cpp)
|
SRCS = $(wildcard $(SRCDIR)/*.cpp)
|
||||||
OBJS = $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRCS))
|
OBJS = $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRCS))
|
||||||
|
|
||||||
all: $(BINDIR)/$(EXECUTABLE)
|
all: $(NAME)
|
||||||
|
|
||||||
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
|
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
|
||||||
$(CXX) $(CXXFLAGS) -c $< -o $@
|
mkdir -p obj
|
||||||
|
$(CXX) $(CPPFLAGS) -c $< -o $@
|
||||||
|
|
||||||
$(BINDIR)/$(EXECUTABLE): $(OBJS)
|
$(NAME): $(OBJS)
|
||||||
$(CXX) $(CXXFLAGS) $^ -o $@
|
$(CXX) $(CPPFLAGS) $^ -o $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(OBJDIR)/*.o
|
rm -rf $(OBJDIR)/*.o
|
||||||
|
|
||||||
fclean: clean
|
fclean: clean
|
||||||
rm -fr $(BINDIR)/$(EXECUTABLE)
|
rm -fr $(NAME)
|
||||||
|
|
||||||
re: fclean all
|
re: fclean all
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#include <ostream>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@ -8,11 +7,13 @@ int main()
|
|||||||
std::string* stringPTR = &string;
|
std::string* stringPTR = &string;
|
||||||
std::string& stringREF = string;
|
std::string& stringREF = string;
|
||||||
|
|
||||||
std::cout << &string << std::endl;
|
std::cout << "ADDRESS" << std::endl;
|
||||||
std::cout << stringPTR << std::endl;
|
std::cout << "original: " << &string << std::endl;
|
||||||
std::cout << &stringREF << std::endl;
|
std::cout << "pointer: " << stringPTR << std::endl;
|
||||||
|
std::cout << "reference: " << &stringREF << std::endl;
|
||||||
std::cout << string << std::endl;
|
std::cout << std::endl;
|
||||||
std::cout << *stringPTR << std::endl;
|
std::cout << "VALUE" << std::endl;
|
||||||
std::cout << stringREF << std::endl;
|
std::cout << "original: " << string << std::endl;
|
||||||
|
std::cout << "pointer: " << *stringPTR << std::endl;
|
||||||
|
std::cout << "reference: " << stringREF << std::endl;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user