当前位置:网站首页>0x0fa23729 (vcruntime140d.dll) (in classes and objects - encapsulation.Exe) exception thrown (resolved)
0x0fa23729 (vcruntime140d.dll) (in classes and objects - encapsulation.Exe) exception thrown (resolved)
2022-07-07 10:22:00 【qq_ forty-two million one hundred and twenty thousand eight hun】
When running the program 42 That's ok Throw an exception , But I will cpp If the file is put under another solution, there will be no exceptions
#include<iostream>
#include<string>
using namespace std;
class Person
{
public:
// Set name
void setName(string name)
{
m_Name = name;
}
// Get name
string getName()
{
return m_Name;
}
// For age
int getAge()
{
//m_Age = 0; // The initialization age is 0 year
return m_Age;
}
void setAge(int age)
{
if (age < 0 || age > 150)
{
m_Age = 0;// Output error value , Set the age to 0
cout << " The age you entered is incorrect !" << endl;
return; // Exit the current function setAge()
}
m_Age = age;
}
// Set lover
void setLover(string lover)
{
m_Lover = lover;
} //***** There is an exception here ******
private:
string m_Name;// full name Can read but write
int m_Age; // Age Can read but write
string m_Lover; // Lover Just write
};
int main(void)
{
Person p;
// Set lover
p.setLover(" Bridge ");
//cout << " Lover for :" << p.getLover() << endl; // error , Because I didn't get a lover Function of getLover()
system("pause");
return 0;
}
Solution : Put the source file under several cpp After the file is set to exclude from generation , Compile and run again without throwing exceptions , I don't know why , May be able to understand with the deepening of learning .
边栏推荐
猜你喜欢
SQLyog数据库怎么取消自动保存更改
【剑指Offer】42. 栈的压入、弹出序列
This article explains the complex relationship between MCU, arm, muc, DSP, FPGA and embedded system
Remote meter reading, switching on and off operation command
Memory ==c language 1
XML配置文件解析与建模
Use of JSON extractor originals in JMeter
Video based full link Intelligent Cloud? This article explains in detail what Alibaba cloud video cloud "intelligent media production" is
LeetCode 练习——113. 路径总和 II
ORM -- logical relation and & or; Sort operation, update record operation, delete record operation
随机推荐
Download Text, pictures and ab packages used by unitywebrequest Foundation
2022.7.3DAY595
Remote meter reading, switching on and off operation command
Weekly recommended short videos: what are the functions of L2 that we often use in daily life?
【acwing】786. 第k个数
Appx代碼簽名指南
Official media attention! The list of top 100 domestic digital collection platforms was released, and the industry accelerated the healthy development of compliance
Guide de signature du Code Appx
This article explains the complex relationship between MCU, arm, muc, DSP, FPGA and embedded system
ISP、IAP、ICP、JTAG、SWD的编程特点
MCU is the most popular science (ten thousand words summary, worth collecting)
The request object parses the request body and request header parameters
STM32产品介绍
Google colab loads Google drive (Google drive is used in Google colab)
Parameter sniffing (1/2)
ArcGIS operation: converting DWG data to SHP data
ORM--分组查询,聚合查询,查询集QuerySet对象特性
Apprentissage avancé des fonctions en es6
ES6中的函數進階學習
Postman interface test V