[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

C++ Programming :: OOPS Concepts - Discussion

Home > C++ Programming > OOPS Concepts > MCQs Questions Discussion

2 / 14

What statements in the following C++ program would result in compilation error?

char *buff, *data;
void main () 
{
const char* const cp = buff;
cp = data;          // Line 5
*cp='a';            // Line 6
}

ANo compilation error

BOnly Line 5

COnly Line 6

DBoth Line 5 and Line 6

Answer: Option (Login/Signup)

Show Explanation

cp = data; cp is a const variable which means it is read-only. we can not assign values to read-only variables.

*cp='a'; cp is also a const pointer (read only) and we are trying to assign value at its address which throws error at compile time.

Asked In :: Commvault Sopra Steria

Post Your Answer Here:     

Reply    
Rate This: +1 -0 +
    Report


Report Error

Please Login First Click Here