Try compiling the following program: void foo(const int *); int main() { int. v. new int [10); foo(); return 0; 1 The co

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Try compiling the following program: void foo(const int *); int main() { int. v. new int [10); foo(); return 0; 1 The co

Post by answerhappygod »

Try Compiling The Following Program Void Foo Const Int Int Main Int V New Int 10 Foo Return 0 1 The Co 1
Try Compiling The Following Program Void Foo Const Int Int Main Int V New Int 10 Foo Return 0 1 The Co 1 (38.6 KiB) Viewed 75 times
Try compiling the following program: void foo(const int *); int main() { int. v. new int [10); foo(); return 0; 1 The compiler will give you an error because you are converting into to const into the error message looks like this with gec 11.2.8: test.cpp: In function 'int main': test.cpp:5:7: error: invalid conversion from 'int' to 'const int**' [-fpermissive] 5.1 foo(); inte test.cpp:1:10: note: initializing argument 1 of 'void foo(const int +)' 1 | void foo(const intes); Usually it is possible to convert from non-const to const - why is that not possible here? Hint. It is obvious why the following program does not compile: const int bar 0); int main() { intv = new int [10]; V[O] - bar(); return 8; } What does this program have in common with the program above?
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply