unable to read memory with inheritanceHow to get the current directory in a C program?How to determine CPU and memory consumption from inside a process?Inheriting constructorsDifference between private, public, and protected inheritanceRead whole ASCII file into C++ std::stringC++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?Can a local variable's memory be accessed outside its scope?Read file line by line using ifstream in C++Why is reading lines from stdin much slower in C++ than Python?Unable to read memoryMemory Pools and <Unable to read memory>

What are they doing to this rocket following its test fire?

Short story written from alien perspective with this line: "It's too bright to look at, so they don't"

In this example, which path would a monster affected by the Dissonant Whispers spell take?

Are the AT-AT's from Empire Strikes back a deliberate reference to Mecha

How to pass a regex when finding a directory path in bash?

Implement Homestuck's Catenative Doomsday Dice Cascader

Why is the relationship between frequency and pitch exponential?

How do I write "Show, Don't Tell" as an Asperger

Did thousands of women die every year due to illegal abortions before Roe v. Wade?

Why is c4 bad when playing the London against a King's Indian?

Word for a small burst of laughter that can't be held back

How can drunken, homicidal elves successfully conduct a wild hunt?

Credit card offering 0.5 miles for every cent rounded up. Too good to be true?

Will TSA allow me to carry a Continuous Positive Airway Pressure (CPAP)/sleep apnea device?

Incremental Ranges!

What's the correct term for a waitress in the Middle Ages?

Which type of electrical protector is better for the appliances? surge or over/under voltage protection?

Can you please explain this joke: "I'm going bananas is what I tell my bananas before I leave the house"?

Who operates delivery flights for commercial airlines?

What's the logic behind the the organization of Hamburg's bus transport into "rings"?

Calling GPL'ed socket server inside Docker?

What's the correct term describing the action of sending a brand-new ship out into its first seafaring trip?

What risks are there when you clear your cookies instead of logging off?

Movie where a boy is transported into the future by an alien spaceship



unable to read memory with inheritance


How to get the current directory in a C program?How to determine CPU and memory consumption from inside a process?Inheriting constructorsDifference between private, public, and protected inheritanceRead whole ASCII file into C++ std::stringC++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?Can a local variable's memory be accessed outside its scope?Read file line by line using ifstream in C++Why is reading lines from stdin much slower in C++ than Python?Unable to read memoryMemory Pools and <Unable to read memory>






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I cant save & load my data in inheritance class.



when codes are get in to load Function debuger said unable to read memory and cant access to member funtion



Object is super class, CPlayer is subclass



CMainGame::CMainGame()
:player(nullptr),field(nullptr), save_load(nullptr)

field = new CField();
save_load = new CSave_Load;


void CMainGame::select_class()

case 4:
//player = new CPlayer;
player = new CPlayer("", 0.f, 0.f, 0, 0, 0);
save_load->Load(player);
return;



save_load header & cpp



class CSave_Load

public:
CSave_Load();
~CSave_Load();

void Save(class CObject* _player);
void Load(class CObject* _player);
;
//Load Function

void CSave_Load::Load(CObject* _player)

FILE* fp = nullptr;
errno_t err = fopen_s(&fp, "./Data/Save.txt", "rb");
if (err == 0)

fread(_player, sizeof(CObject), 1, fp);
cout << "불러오기 성공" << endl;
fclose(fp);

else
cout << "불러오기 실패" << endl;
system("pause");










share|improve this question
























  • Maybe you should explain what is CObject? If you have something else than very basic type, you should write serialization/deserialization.

    – mpromonet
    Mar 24 at 14:50











  • Cobject is super class for CPlayer which has struct in basic type, and constructor, destructor and some member function

    – 문형준
    Mar 24 at 15:01











  • if you read sizeof(CObject), you will not get a CObject, not a CPlayer. You need to implement proper serialization/deserialization mechanism, or use a library that do this.

    – mpromonet
    Mar 24 at 21:31


















0















I cant save & load my data in inheritance class.



when codes are get in to load Function debuger said unable to read memory and cant access to member funtion



Object is super class, CPlayer is subclass



CMainGame::CMainGame()
:player(nullptr),field(nullptr), save_load(nullptr)

field = new CField();
save_load = new CSave_Load;


void CMainGame::select_class()

case 4:
//player = new CPlayer;
player = new CPlayer("", 0.f, 0.f, 0, 0, 0);
save_load->Load(player);
return;



save_load header & cpp



class CSave_Load

public:
CSave_Load();
~CSave_Load();

void Save(class CObject* _player);
void Load(class CObject* _player);
;
//Load Function

void CSave_Load::Load(CObject* _player)

FILE* fp = nullptr;
errno_t err = fopen_s(&fp, "./Data/Save.txt", "rb");
if (err == 0)

fread(_player, sizeof(CObject), 1, fp);
cout << "불러오기 성공" << endl;
fclose(fp);

else
cout << "불러오기 실패" << endl;
system("pause");










share|improve this question
























  • Maybe you should explain what is CObject? If you have something else than very basic type, you should write serialization/deserialization.

    – mpromonet
    Mar 24 at 14:50











  • Cobject is super class for CPlayer which has struct in basic type, and constructor, destructor and some member function

    – 문형준
    Mar 24 at 15:01











  • if you read sizeof(CObject), you will not get a CObject, not a CPlayer. You need to implement proper serialization/deserialization mechanism, or use a library that do this.

    – mpromonet
    Mar 24 at 21:31














0












0








0








I cant save & load my data in inheritance class.



when codes are get in to load Function debuger said unable to read memory and cant access to member funtion



Object is super class, CPlayer is subclass



CMainGame::CMainGame()
:player(nullptr),field(nullptr), save_load(nullptr)

field = new CField();
save_load = new CSave_Load;


void CMainGame::select_class()

case 4:
//player = new CPlayer;
player = new CPlayer("", 0.f, 0.f, 0, 0, 0);
save_load->Load(player);
return;



save_load header & cpp



class CSave_Load

public:
CSave_Load();
~CSave_Load();

void Save(class CObject* _player);
void Load(class CObject* _player);
;
//Load Function

void CSave_Load::Load(CObject* _player)

FILE* fp = nullptr;
errno_t err = fopen_s(&fp, "./Data/Save.txt", "rb");
if (err == 0)

fread(_player, sizeof(CObject), 1, fp);
cout << "불러오기 성공" << endl;
fclose(fp);

else
cout << "불러오기 실패" << endl;
system("pause");










share|improve this question
















I cant save & load my data in inheritance class.



when codes are get in to load Function debuger said unable to read memory and cant access to member funtion



Object is super class, CPlayer is subclass



CMainGame::CMainGame()
:player(nullptr),field(nullptr), save_load(nullptr)

field = new CField();
save_load = new CSave_Load;


void CMainGame::select_class()

case 4:
//player = new CPlayer;
player = new CPlayer("", 0.f, 0.f, 0, 0, 0);
save_load->Load(player);
return;



save_load header & cpp



class CSave_Load

public:
CSave_Load();
~CSave_Load();

void Save(class CObject* _player);
void Load(class CObject* _player);
;
//Load Function

void CSave_Load::Load(CObject* _player)

FILE* fp = nullptr;
errno_t err = fopen_s(&fp, "./Data/Save.txt", "rb");
if (err == 0)

fread(_player, sizeof(CObject), 1, fp);
cout << "불러오기 성공" << endl;
fclose(fp);

else
cout << "불러오기 실패" << endl;
system("pause");







c++






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 24 at 14:29







문형준

















asked Mar 24 at 14:25









문형준문형준

32




32












  • Maybe you should explain what is CObject? If you have something else than very basic type, you should write serialization/deserialization.

    – mpromonet
    Mar 24 at 14:50











  • Cobject is super class for CPlayer which has struct in basic type, and constructor, destructor and some member function

    – 문형준
    Mar 24 at 15:01











  • if you read sizeof(CObject), you will not get a CObject, not a CPlayer. You need to implement proper serialization/deserialization mechanism, or use a library that do this.

    – mpromonet
    Mar 24 at 21:31


















  • Maybe you should explain what is CObject? If you have something else than very basic type, you should write serialization/deserialization.

    – mpromonet
    Mar 24 at 14:50











  • Cobject is super class for CPlayer which has struct in basic type, and constructor, destructor and some member function

    – 문형준
    Mar 24 at 15:01











  • if you read sizeof(CObject), you will not get a CObject, not a CPlayer. You need to implement proper serialization/deserialization mechanism, or use a library that do this.

    – mpromonet
    Mar 24 at 21:31

















Maybe you should explain what is CObject? If you have something else than very basic type, you should write serialization/deserialization.

– mpromonet
Mar 24 at 14:50





Maybe you should explain what is CObject? If you have something else than very basic type, you should write serialization/deserialization.

– mpromonet
Mar 24 at 14:50













Cobject is super class for CPlayer which has struct in basic type, and constructor, destructor and some member function

– 문형준
Mar 24 at 15:01





Cobject is super class for CPlayer which has struct in basic type, and constructor, destructor and some member function

– 문형준
Mar 24 at 15:01













if you read sizeof(CObject), you will not get a CObject, not a CPlayer. You need to implement proper serialization/deserialization mechanism, or use a library that do this.

– mpromonet
Mar 24 at 21:31






if you read sizeof(CObject), you will not get a CObject, not a CPlayer. You need to implement proper serialization/deserialization mechanism, or use a library that do this.

– mpromonet
Mar 24 at 21:31













2 Answers
2






active

oldest

votes


















0














Are you using VisualStudio?



It is possible that the directory from which the EXE is being run, is not the source code directory, as VisualStudio builds out of source.



What happens when you full path? The code seems "OK"ish, but it's really hard to guess without seeing the full picture.






share|improve this answer























  • yes i'm using Visual Studio 2015. i think that code is OK too. and it sometimes run normaly... can i send my full project??

    – 문형준
    Mar 24 at 15:05











  • No you don't :) But... look into the settings - and verify that the project is running from the source directory and not build directory.

    – elcuco
    Mar 24 at 15:10











  • how can i check them?

    – 문형준
    Mar 24 at 15:16











  • Just a side note - you marked the answer as accepted. However, you still did not fix the problem.. so... Regarding the "how do I check"... look in the project settings. Eventually you will find it (not using VisualStudio - can't help you there). However - here is a hint: stackoverflow.com/questions/298510/…

    – elcuco
    Mar 24 at 15:37












  • i found project files but i cant solve my problem lol but it was helpful. i should ask this problem to my professor

    – 문형준
    Mar 24 at 15:56


















0














finally i solve this problem by sending struct for argument in save, load function
Compiler didn't know CObject or CPlayer size because they are too heavy



INFO* CSave_Load::Load(INFO* _info)

FILE* fp = nullptr;
errno_t err = fopen_s(&fp, "./Data/Save.txt", "rb");
if (err == 0)

fread(_info, sizeof(INFO), 1, fp);
cout << "불러오기 성공" << endl;
fclose(fp);

else
cout << "불러오기 실패" << endl;
system("pause");
return _info;



INFO is struct in CObject class






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55324799%2funable-to-read-memory-with-inheritance%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Are you using VisualStudio?



    It is possible that the directory from which the EXE is being run, is not the source code directory, as VisualStudio builds out of source.



    What happens when you full path? The code seems "OK"ish, but it's really hard to guess without seeing the full picture.






    share|improve this answer























    • yes i'm using Visual Studio 2015. i think that code is OK too. and it sometimes run normaly... can i send my full project??

      – 문형준
      Mar 24 at 15:05











    • No you don't :) But... look into the settings - and verify that the project is running from the source directory and not build directory.

      – elcuco
      Mar 24 at 15:10











    • how can i check them?

      – 문형준
      Mar 24 at 15:16











    • Just a side note - you marked the answer as accepted. However, you still did not fix the problem.. so... Regarding the "how do I check"... look in the project settings. Eventually you will find it (not using VisualStudio - can't help you there). However - here is a hint: stackoverflow.com/questions/298510/…

      – elcuco
      Mar 24 at 15:37












    • i found project files but i cant solve my problem lol but it was helpful. i should ask this problem to my professor

      – 문형준
      Mar 24 at 15:56















    0














    Are you using VisualStudio?



    It is possible that the directory from which the EXE is being run, is not the source code directory, as VisualStudio builds out of source.



    What happens when you full path? The code seems "OK"ish, but it's really hard to guess without seeing the full picture.






    share|improve this answer























    • yes i'm using Visual Studio 2015. i think that code is OK too. and it sometimes run normaly... can i send my full project??

      – 문형준
      Mar 24 at 15:05











    • No you don't :) But... look into the settings - and verify that the project is running from the source directory and not build directory.

      – elcuco
      Mar 24 at 15:10











    • how can i check them?

      – 문형준
      Mar 24 at 15:16











    • Just a side note - you marked the answer as accepted. However, you still did not fix the problem.. so... Regarding the "how do I check"... look in the project settings. Eventually you will find it (not using VisualStudio - can't help you there). However - here is a hint: stackoverflow.com/questions/298510/…

      – elcuco
      Mar 24 at 15:37












    • i found project files but i cant solve my problem lol but it was helpful. i should ask this problem to my professor

      – 문형준
      Mar 24 at 15:56













    0












    0








    0







    Are you using VisualStudio?



    It is possible that the directory from which the EXE is being run, is not the source code directory, as VisualStudio builds out of source.



    What happens when you full path? The code seems "OK"ish, but it's really hard to guess without seeing the full picture.






    share|improve this answer













    Are you using VisualStudio?



    It is possible that the directory from which the EXE is being run, is not the source code directory, as VisualStudio builds out of source.



    What happens when you full path? The code seems "OK"ish, but it's really hard to guess without seeing the full picture.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 24 at 14:45









    elcucoelcuco

    5,96573558




    5,96573558












    • yes i'm using Visual Studio 2015. i think that code is OK too. and it sometimes run normaly... can i send my full project??

      – 문형준
      Mar 24 at 15:05











    • No you don't :) But... look into the settings - and verify that the project is running from the source directory and not build directory.

      – elcuco
      Mar 24 at 15:10











    • how can i check them?

      – 문형준
      Mar 24 at 15:16











    • Just a side note - you marked the answer as accepted. However, you still did not fix the problem.. so... Regarding the "how do I check"... look in the project settings. Eventually you will find it (not using VisualStudio - can't help you there). However - here is a hint: stackoverflow.com/questions/298510/…

      – elcuco
      Mar 24 at 15:37












    • i found project files but i cant solve my problem lol but it was helpful. i should ask this problem to my professor

      – 문형준
      Mar 24 at 15:56

















    • yes i'm using Visual Studio 2015. i think that code is OK too. and it sometimes run normaly... can i send my full project??

      – 문형준
      Mar 24 at 15:05











    • No you don't :) But... look into the settings - and verify that the project is running from the source directory and not build directory.

      – elcuco
      Mar 24 at 15:10











    • how can i check them?

      – 문형준
      Mar 24 at 15:16











    • Just a side note - you marked the answer as accepted. However, you still did not fix the problem.. so... Regarding the "how do I check"... look in the project settings. Eventually you will find it (not using VisualStudio - can't help you there). However - here is a hint: stackoverflow.com/questions/298510/…

      – elcuco
      Mar 24 at 15:37












    • i found project files but i cant solve my problem lol but it was helpful. i should ask this problem to my professor

      – 문형준
      Mar 24 at 15:56
















    yes i'm using Visual Studio 2015. i think that code is OK too. and it sometimes run normaly... can i send my full project??

    – 문형준
    Mar 24 at 15:05





    yes i'm using Visual Studio 2015. i think that code is OK too. and it sometimes run normaly... can i send my full project??

    – 문형준
    Mar 24 at 15:05













    No you don't :) But... look into the settings - and verify that the project is running from the source directory and not build directory.

    – elcuco
    Mar 24 at 15:10





    No you don't :) But... look into the settings - and verify that the project is running from the source directory and not build directory.

    – elcuco
    Mar 24 at 15:10













    how can i check them?

    – 문형준
    Mar 24 at 15:16





    how can i check them?

    – 문형준
    Mar 24 at 15:16













    Just a side note - you marked the answer as accepted. However, you still did not fix the problem.. so... Regarding the "how do I check"... look in the project settings. Eventually you will find it (not using VisualStudio - can't help you there). However - here is a hint: stackoverflow.com/questions/298510/…

    – elcuco
    Mar 24 at 15:37






    Just a side note - you marked the answer as accepted. However, you still did not fix the problem.. so... Regarding the "how do I check"... look in the project settings. Eventually you will find it (not using VisualStudio - can't help you there). However - here is a hint: stackoverflow.com/questions/298510/…

    – elcuco
    Mar 24 at 15:37














    i found project files but i cant solve my problem lol but it was helpful. i should ask this problem to my professor

    – 문형준
    Mar 24 at 15:56





    i found project files but i cant solve my problem lol but it was helpful. i should ask this problem to my professor

    – 문형준
    Mar 24 at 15:56













    0














    finally i solve this problem by sending struct for argument in save, load function
    Compiler didn't know CObject or CPlayer size because they are too heavy



    INFO* CSave_Load::Load(INFO* _info)

    FILE* fp = nullptr;
    errno_t err = fopen_s(&fp, "./Data/Save.txt", "rb");
    if (err == 0)

    fread(_info, sizeof(INFO), 1, fp);
    cout << "불러오기 성공" << endl;
    fclose(fp);

    else
    cout << "불러오기 실패" << endl;
    system("pause");
    return _info;



    INFO is struct in CObject class






    share|improve this answer



























      0














      finally i solve this problem by sending struct for argument in save, load function
      Compiler didn't know CObject or CPlayer size because they are too heavy



      INFO* CSave_Load::Load(INFO* _info)

      FILE* fp = nullptr;
      errno_t err = fopen_s(&fp, "./Data/Save.txt", "rb");
      if (err == 0)

      fread(_info, sizeof(INFO), 1, fp);
      cout << "불러오기 성공" << endl;
      fclose(fp);

      else
      cout << "불러오기 실패" << endl;
      system("pause");
      return _info;



      INFO is struct in CObject class






      share|improve this answer

























        0












        0








        0







        finally i solve this problem by sending struct for argument in save, load function
        Compiler didn't know CObject or CPlayer size because they are too heavy



        INFO* CSave_Load::Load(INFO* _info)

        FILE* fp = nullptr;
        errno_t err = fopen_s(&fp, "./Data/Save.txt", "rb");
        if (err == 0)

        fread(_info, sizeof(INFO), 1, fp);
        cout << "불러오기 성공" << endl;
        fclose(fp);

        else
        cout << "불러오기 실패" << endl;
        system("pause");
        return _info;



        INFO is struct in CObject class






        share|improve this answer













        finally i solve this problem by sending struct for argument in save, load function
        Compiler didn't know CObject or CPlayer size because they are too heavy



        INFO* CSave_Load::Load(INFO* _info)

        FILE* fp = nullptr;
        errno_t err = fopen_s(&fp, "./Data/Save.txt", "rb");
        if (err == 0)

        fread(_info, sizeof(INFO), 1, fp);
        cout << "불러오기 성공" << endl;
        fclose(fp);

        else
        cout << "불러오기 실패" << endl;
        system("pause");
        return _info;



        INFO is struct in CObject class







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 26 at 1:08









        문형준문형준

        32




        32



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55324799%2funable-to-read-memory-with-inheritance%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해