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