C++ unresolved external symbol

前端 未结 4 1517
说谎
说谎 2021-01-12 21:04

Hi iam begginer at c++ i have class with static methods and i cant access them it throws me an error

    1>------ Build started: Project: CPractice, Confi         


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-12 21:43

    Since name is a static data member you should initialize it :) and not count on the default instance related constructor.

    Add this after the class definitions (yep, I know its confusing since your member is a private one, but this is only an initialization) :

    string CPractice::name;
    

提交回复
热议问题