Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

string s1 = -1;
in my code, i mistakenly add s1 as -1. is that any possible to get core dump because no error and warning is showing at compilation.

What I have tried:

i described my issue, this question why means if again i give s1 as some string means no issue will give. for my clarification am asking this.
Posted
Updated 6-Oct-21 21:25pm
Comments
KarstenK 7-Oct-21 5:01am    
Learn to respect the compiler as it knows a lot of coding and is most smarter than the person sitting in front of it ;-)

1 solution

That's unlikely: assigning an integer to a string variable will give an error in every implementation of C++ I've used:
main.cpp:16:13: error: conversion from ‘int’ to non-scalar type ‘std::string’ {aka ‘std::__cxx11::basic_string’} requested
   16 | string s1 = -1;
And that prevents your revised code from generating an EXE file and therefore from running at all...
 
Share this answer
 
Comments
maathesh 7-Oct-21 3:46am    
hi, actually this part from my project i initialize in struct constructor
CPallini 7-Oct-21 4:09am    
Then, please, show the ACTUAL code.
CPallini 7-Oct-21 4:09am    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900