월 24,200원
5개월 할부 시다른 수강생들이 자주 물어보는 질문이 궁금하신가요?
- 미해결홍정모의 따라하며 배우는 C++
namespace 관련 질문
결과값은 잘 나오는데 컴파일 관련 오류가 있는 것 같습니다해결방법 알 수 있을까요??
- 해결됨홍정모의 따라하며 배우는 C++
너무 옛날 강의 ..
이거 보니까 2018년도에 녹화하신건데 지금 2023년 한달뒤면 2024년인데 내용이 너무 뒤쳐지지는 않을까여 ? 저는 초보자라서 잘 모르는데 고수분들이 보기에는 어떤것 같나여 ?? 답변좀 부탁드립니다!
- 미해결홍정모의 따라하며 배우는 C++
맥북 터미널로 실행
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 말씀해주신 유튜브 링크로 맥북 visual studio code 세팅중인데 터미널에서 실행하는 방법대로 하니 저는 안되는데 왜 그럴까요....? zsh : command not found: code 로 뜨네요
- 미해결홍정모의 따라하며 배우는 C++
vscode 에서 c++을 사용하면 솔루션은 안만들어도 되는건가요?
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요.vscode 에서 c++을 사용하면 솔루션은 안만들어도 되는건가요? 솔루션 안에 프로젝트를 만들라고 하는데 vscode에서는 프로젝트만 만들면 되는거 맞을까요?
- 미해결홍정모의 따라하며 배우는 C++
vsc에서 bool b3{ true }; 빌드 관련질문
vsc에서 bool b3{ true };이 코드에서 빌드 오류가 나는거 같은데b3뒤에 ;이 빠졌다고 나오는데 어떻게 해결하는지 잘 모르겠습니다
- 미해결홍정모의 따라하며 배우는 C++
상속-base class undefined
안녕하세요, 제가 며칠 잠을 못자서 그런지 계속 상속에서 에러가 나네요..개념도 다시 한번 정비하려고 강의도 정주행 중인데, 며칠 째 못풀어서 답답해서 일단 질문드립니다.ㅠ조금 긴 코드이지만 염치 불구하고 혹시 도와주신다면 정말로 감사할 것 같습니다.우선, menu를 userMenu에서 상속받고 몇가지 변수들도 추가하고자 하여, virtual function-override를 사용해보았습니다.그런데 계속해서Severity Code Description Project File Line Suppression StateError C3668 'UserMenu::handleEvents': method with override specifier 'override' did not override any base class methodsSeverity Code Description Project File Line Suppression StateError C2504 'Menu': base class undefined이와 같은 오류가 납니다.virtual function 선언 때 0을 부여해도 마찬가지입니다. // 우선 userMenu.h 와 .cpp 입니다. #pragma once #ifndef USER_MENU_H #define USER_MENU_H #include "menu.h" #include "gameDisplay.h" class UserMenu : public Menu { public: UserMenu(); void u_run(); void handleEvents() override; protected: sf::Text subText; sf::Text buttonSecond; sf::RectangleShape borderSecond; sf::Text buttonThird; sf::RectangleShape borderThird; }; #endif // .cpp #include "userMenu.h" UserMenu::UserMenu() : Menu() { subText.setString(" - user mode - "); subText.setFont(font); subText.setCharacterSize(30); subText.setFillColor(sf::Color::White); sf::FloatRect managerRect = subText.getLocalBounds(); subText.setPosition((window.getSize().x - managerRect.width) / 2, (window.getSize().y - managerRect.height) / 2 - 170); // 2 buttonSecond.setString("2. WORD GAME"); buttonSecond.setFont(font); buttonSecond.setCharacterSize(50); buttonSecond.setFillColor(sf::Color::White); sf::FloatRect buttonSecondRect = buttonSecond.getLocalBounds(); // left // down buttonSecond.setPosition((window.getSize().x - buttonSecondRect.width) / 2, (window.getSize().y - buttonSecondRect.height) / 2 + 10); // 3 buttonThird.setString("3. PROFILE & USERS"); buttonThird.setFont(font); buttonThird.setCharacterSize(50); buttonThird.setFillColor(sf::Color::White); sf::FloatRect buttonThirdRect = buttonThird.getLocalBounds(); // left // down buttonThird.setPosition((window.getSize().x - buttonThirdRect.width) / 2, (window.getSize().y - buttonThirdRect.height) / 2 + 110); window.draw(buttonSecond); window.draw(buttonThird); u_run(); } void UserMenu::u_run() { while (window.isOpen()) { createDisplay(); createButton(); handleEvents(); render(); } } void UserMenu::handleEvents() { sf::Event event; while (window.pollEvent(event)) { sf::Vector2f mousePos(event.mouseButton.x, event.mouseButton.y); if (event.type == sf::Event::Closed) { window.close(); } else if (event.type == sf::Event::MouseButtonPressed) { if (buttonSecond.getGlobalBounds().contains(mousePos)) { playClick(); std::cout << "Second button clicked! Opening new window..." << std::endl; window.close(); GameDisplay gameDisplay; gameDisplay.run(); } else if (buttonThird.getGlobalBounds().contains(mousePos)) { playClick(); std::cout << "Third button clicked! Opening new window..." << std::endl; window.close(); CurrentProfile currentProfile; // later must be replaced currentProfile.run(); } } else if (event.type == sf::Event::MouseMoved) { if (buttonFirst.getGlobalBounds().contains(sf::Vector2f(event.mouseMove.x, event.mouseMove.y))) { buttonFirst.setFillColor(sf::Color::Red); } else { buttonFirst.setFillColor(sf::Color::White); } if (buttonSecond.getGlobalBounds().contains(sf::Vector2f(event.mouseMove.x, event.mouseMove.y))) { buttonSecond.setFillColor(sf::Color::Red); } else { buttonSecond.setFillColor(sf::Color::White); } if (buttonThird.getGlobalBounds().contains(sf::Vector2f(event.mouseMove.x, event.mouseMove.y))) { buttonThird.setFillColor(sf::Color::Red); } else { buttonThird.setFillColor(sf::Color::White); } } } }// menu.h와 .cpp입니다. #ifndef MENU_H #define MENU_H #include "loginSystem.h" #include "currentProfile.h" class Menu { public: Menu(); void run(); void playClick(); sf::SoundBuffer clickBuffer; sf::Sound clickSound; virtual void createDisplay(); void createButton(); virtual void handleEvents(); // = 0 해도 결과는 같음(에러) void render(); sf::RenderWindow window; sf::Font font; sf::Text mainText; sf::Text backButton; sf::RectangleShape borderRect; bool isManager; sf::Font m_font; sf::Text buttonFirst; sf::RectangleShape borderFirst; }; #endif #include "menu.h" Menu::Menu() : window(sf::VideoMode(1400, 700), "Menu Display") { } void Menu::run() { while (window.isOpen()) { createDisplay(); createButton(); handleEvents(); render(); } } void Menu::createDisplay() { if (!font.loadFromFile("font/hangthedj.ttf")) { std::cerr << "Failed to load font!" << std::endl; } mainText.setString("let's practice together"); mainText.setFont(font); mainText.setCharacterSize(70); mainText.setFillColor(sf::Color::White); sf::FloatRect textRect = mainText.getLocalBounds(); mainText.setPosition((window.getSize().x - textRect.width) / 2, (window.getSize().y - textRect.height) / 2 - 240); // Back button backButton.setString("BACK"); backButton.setFont(font); backButton.setCharacterSize(30); backButton.setFillColor(sf::Color::White); sf::FloatRect loginButtonRect = backButton.getLocalBounds(); // left // down backButton.setPosition((window.getSize().x - loginButtonRect.width) - 250, (window.getSize().y - loginButtonRect.height) / 2 + 180); borderRect.setSize(sf::Vector2f(loginButtonRect.width + 10, loginButtonRect.height + 10)); borderRect.setPosition((window.getSize().x - loginButtonRect.width) - 253, (window.getSize().y - loginButtonRect.height) / 2 + 180); borderRect.setFillColor(sf::Color::Transparent); borderRect.setOutlineThickness(4); borderRect.setOutlineColor(sf::Color::White); } void Menu::createButton() { if (!m_font.loadFromFile("font/RobotoSlab-Bold.ttf")) { std::cerr << "Failed to load font!" << std::endl; } // 1 buttonFirst.setString("1. VOCABULARY"); buttonFirst.setFont(m_font); buttonFirst.setCharacterSize(50); buttonFirst.setFillColor(sf::Color::White); sf::FloatRect buttonFirstRect = buttonFirst.getLocalBounds(); // left buttonFirst.setPosition((window.getSize().x - buttonFirstRect.width) / 2, (window.getSize().y - buttonFirstRect.height) / 2 - 70); } void Menu::playClick() { if (clickBuffer.loadFromFile("media/click_sound.wav")) { clickSound.setBuffer(clickBuffer); clickSound.play(); } else { std::cerr << "Failed to load click sound file!" << std::endl; } } void Menu::handleEvents() { sf::Event event; while (window.pollEvent(event)) { sf::Vector2f mousePos(event.mouseButton.x, event.mouseButton.y); if (event.type == sf::Event::Closed) { window.close(); } else if (event.type == sf::Event::MouseButtonPressed) { if (buttonFirst.getGlobalBounds().contains(mousePos)) { playClick(); std::cout << "First button clicked! Opening new window..." << std::endl; window.close(); // insert run } else if (backButton.getGlobalBounds().contains(mousePos)) { playClick(); std::cout << "BACK button clicked! Opening previous window..." << std::endl; window.close(); LoginSystem loginSystem; loginSystem.run(); } } else if (event.type == sf::Event::MouseMoved) { if (buttonFirst.getGlobalBounds().contains(sf::Vector2f(event.mouseMove.x, event.mouseMove.y))) { buttonFirst.setFillColor(sf::Color::Red); } else { buttonFirst.setFillColor(sf::Color::White); } if (backButton.getGlobalBounds().contains(sf::Vector2f(event.mouseMove.x, event.mouseMove.y))) { backButton.setFillColor(sf::Color::Red); borderRect.setOutlineColor(sf::Color::Red); } else { backButton.setFillColor(sf::Color::White); borderRect.setOutlineColor(sf::Color::White); } } } } void Menu::render() { window.clear(); window.draw(mainText); window.draw(backButton); window.draw(borderRect); window.draw(buttonFirst); window.draw(borderFirst); window.display(); }
- 미해결홍정모의 따라하며 배우는 C++
부모 클래스의 멤버변수가 상속될 때 초기화
class Child :public Mother { private: double m_d; public: Child() :m_d(1.0), m_i(10) { cout << "child constructor" << endl; } };위 코드에서 오류가 나는 이유가 Child객체를 실행할 때 m_d와 m_i에 메모리를 주는 과정에서 child객체가 m_i가 무엇인지 인식을 하지 못하기 때문에 에러가 난다고 이해했는데 맞게 생각한걸까요?
- 미해결홍정모의 따라하며 배우는 C++
복사생성자
class Fraction { private: int m_numerator; int m_denominator; public: Fraction(int num = 0, int den = 1) :m_numerator(num), m_denominator(den) { assert(den != 0); } Fraction(Fraction& fraction) :m_numerator(fraction.m_numerator), m_denominator(fraction.m_denominator) { cout << "copy constructor called" << endl; } friend std::ostream& operator<<(std::ostream& out, const Fraction& f) { cout << f.m_numerator << "/" << f.m_denominator << endl; return cout; } }; int main() { Fraction frac(3, 5); Fraction fr_copy( Fraction(3,10) ); cout << frac << " " << fr_copy << endl; return 0; }복사생성자에서 const키워드가 없을때 오류가 발생하는 이유가 궁금합니다.Fraction fr_copy( Fraction(3,10) );위 부분에서Error C2558 class 'Fraction': no copy constructor available or copy constructor is declared 'explicit'이렇게 에러가 발생합니다
- 미해결홍정모의 따라하며 배우는 C++
헤더파일 만들기 (vs code)
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. vs code에서는 add.cpp를 만들어서 main.cpp로 연결하려면 어떻게 해야하나요?
- 미해결홍정모의 따라하며 배우는 C++
강의를 들으면서 질문이 생겼습니다.
void doSomething(int num) { cout << (uintptr_t)&num << endl; cout << num << endl; } int main() { int num = 1; cout << (uintptr_t)&num << endl; cout << num << endl; doSomething(num); return 0; } 안녕하세요. 공부하다가 궁금한게 생겨서 질문드립니다.배열 뿐만 아니라 정수를 파라미터로 받을 때도 포인터로 받는 것이고그 포인터에 받은 변수의 주소가 저장이 되어 있는 건가요?예를들어 main 함수의 num 의 주소와값이 1480 - 1이라고 할때 doSomething함수의 num의 주소값은 1436이고 이 주소가 1480 - 1을 담고있는 것일까요??
- 미해결홍정모의 따라하며 배우는 C++
visual studio for mac c++ 선택
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 문의 드렸을 때 c++로 변경하라고 하셨는데 c++ 자체가 없습니다... ㅜㅜ
- 해결됨홍정모의 따라하며 배우는 C++
7.12 재귀함수 첫번째 예제부터 이해가 안됩니다.
카운트다운 함수가 -1 되는건 이해가 되는데, 다시 0에서 +1 되는게 이해가 안돼요.
- 미해결홍정모의 따라하며 배우는 C++
#include 오류가 발생합니다
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요.강의와 같이 작성했는데 오류가 발생합니다.
- 미해결홍정모의 따라하며 배우는 C++
34:02초 질문드립니다!
34:02초 보시면 초기화를 안해줘서 메모리가 할당이 안되었다고 말씀해 주셨는데,선언만 해주면 메모리는 할당이 되지만, 쓰레기 값이 들어가있는거 아닌가요? 제가 기존에 알고있던 개념과 달라서 헷갈립니다...
- 미해결홍정모의 따라하며 배우는 C++
visual studio for mac 사용법
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. visual studio for mac 을 다운받았는데 강의와 설정하는 방법이 다른 것 같아서 문의드립니다.혹시 참고할만한 영상이나 글 있을까요?
- 미해결홍정모의 따라하며 배우는 C++
실제로 저장 될때는 다르게 저장이 되는거죠?
강의에서는 가독성 때문에 0000_0101이렇게 설명을 해주셨는데예를들어 int i =5; 라는 값이 저장이 될때는 4바이트니까32비트를 사용하기에0000_0000_0000_0000_0000_0000_0000_0101이렇게 되는게 맞나요?그리고 만약 -5라면 2의 보수 취해주고 1을 더해준값1111_1111_1111_1111_1111_1111_1111_1011제가 생각한게 맞을까요???
- 미해결홍정모의 따라하며 배우는 C++
재귀함수 디버깅중 함수에 들어가고 count에 1값이 들어가는 이유
값이 1 이들어가고 그다음에 5값이 들어가는 이유가 무엇때문일까요??
- 해결됨홍정모의 따라하며 배우는 C++
친구 클래스를 선언할 때, 꼭 전방선언이 필요한가요?
#include <iostream> using namespace std; // class B; -> 반드시 필요한가? class A { private: int num1 = 10; friend class B; }; class B { private: int num2 = 5; public: void print(A& a) { cout << a.num1 << endl; } }; int main() { A a; B b; b.print(a); } 강의 7분 경에, friend class B;를 선언하면서 "forward declaration을 피할 수 없는 상태다"라고 하셨는데, 위 코드를 실행해보면 오류가 발생하질 않아요. 제가 보기에도 처음에 클래스 A에서는 클래스 B를 알 방법이 없는 것 같은데..
- 미해결홍정모의 따라하며 배우는 C++
visual studio code
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 강의에서 사용하고 있는 visual studio code 와 지금 버전이 조금 다른데 지금 버전 사용법이 따로 있을까요?맥북 m1 사용중입니다
- 미해결홍정모의 따라하며 배우는 C++
@26:20 static 관련 질문
@26:20 에 "일단 이 static 은 문법상 이 전역변수가 다른 cpp 파일에서 사용될 수 없도록 막아주는 역할을 해요" 의 의미가 링킹시, namespace 혹은 class 내부에 static 이 정의 되어있지 않으면 다른 cpp 파일에서 접근할수 없기 때문인게 맞을까요? 접근 제한자의 느낌은 아닌것같고, extern variable 과 비교하기 위해서 설명을 저렇게 하신건지 궁금합니다. !