feat(ex02): it works
This commit is contained in:
parent
1a167101bb
commit
8f7b9c3068
3 changed files with 53 additions and 0 deletions
1
ex02/.gitignore
vendored
Normal file
1
ex02/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
ex02
|
||||
38
ex02/Makefile
Normal file
38
ex02/Makefile
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
NAME = ex02
|
||||
ifeq ($(CPPFLAGS),)
|
||||
CPPFLAGS = -Wall -Wextra -Werror -std=c++98 -g
|
||||
endif
|
||||
ifeq ($(CXX),)
|
||||
CXX = c++
|
||||
endif
|
||||
# g++ is the default on 42 computers
|
||||
ifeq ($(CXX),g++)
|
||||
CXX = c++
|
||||
endif
|
||||
srcs = \
|
||||
|
||||
main_objs = main.o $(srcs:.cpp=.o)
|
||||
all_objs = $(main_objs)
|
||||
deps = $(all_objs:.o=.d)
|
||||
|
||||
all: $(NAME)
|
||||
|
||||
-include $(deps)
|
||||
|
||||
$(NAME): $(main_objs)
|
||||
$(CXX) $(CPPFLAGS) -o $@ $^
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) -c $(CPPFLAGS) -o $*.o $*.cpp
|
||||
$(CXX) -MM $(CPPFLAGS) -MT $*.o $*.cpp > $*.d
|
||||
|
||||
clean:
|
||||
find . -name '*.o' -print -delete
|
||||
find . -name '*.d' -print -delete
|
||||
|
||||
fclean: clean
|
||||
rm -f $(NAME)
|
||||
|
||||
re:
|
||||
+make fclean
|
||||
+make all
|
||||
14
ex02/main.cpp
Normal file
14
ex02/main.cpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include <iostream>
|
||||
|
||||
int main(void) {
|
||||
std::string string = "HI THIS IS BRAIN";
|
||||
std::string *stringPTR = &string;
|
||||
std::string &stringREF = string;
|
||||
std::cout << "address of string: " << &string << std::endl;
|
||||
std::cout << "address held by stringPTR: " << stringPTR << std::endl;
|
||||
std::cout << "address held by stringREF: " << &stringREF << std::endl;
|
||||
std::cout << "value of string: " << string << std::endl;
|
||||
std::cout << "value pointed by stringPTR: " << *stringPTR << std::endl;
|
||||
std::cout << "value pointed by stringREF: " << stringREF << std::endl;
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue