Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

TICPP Task unsolvable?

Name: Anonymous 2007-09-09 14:14 ID:cr2lSJc3

#include <iostream>

using namespace std;

int main(int argc, char *argv[]){
    const double c_arr[5] = { 1.0 , 10.0 , 1.0, 10.0 , 1.0 };
    volatile double v_arr[5] = { 1.0 , 10.0 , 1.0, 10.0 , 1.0 };
    double *var;
    for(int i=0; i<5;i++){
        var = const_cast<double*>(&c_arr[i]);
        *var=i*10;
        cout << "casted from const: [" << i << "] " << c_arr[i] << endl;
    }
    for(int i=0; i<5 ; i++ ){
        var = const_cast<double*>(&v_arr[i]);
        *var=i*10;
        cout << "casted from volatile: [" << i << "] " << v_arr[i] << endl;
    }
    return 0;
}

/*
Create a const array of double and a volatile array of double. Index through each array and use const_cast to cast each element to non-const and non-volatile, respectively, and assign a value to each element.
*/


The task in comments is from the book "Thinking in C++" 3rd chapter 27th task.
I mean I know that I shouldn't be able to change a const, but I can't let it be uninitialized or that will give me an error (at least the const). So please 4chan explain to me how I am supposed to solve this task?
btw. I am on Linux if that makes a difference which it shouldn't for such a basic Program.

Name: Anonymous 2007-09-11 13:29 ID:KFd+FxVf

EVERY SINGLE programming language is bad in the opinion of /prog/ after a few posts in a thread roughly about that language.

to sum up /prog/ some in befores:
ruby sucks
C sucks
python sucks
Java sucks (no really it does)
perl sucks
D sucks
C++ sucks
LISP sucks
php sucks
PROLOG sucks
pascal sucks
delphi sucks even more
fortan sucks
Java script sucks
C# sucks (badly)
Visual Basic sucks (even worse)
and last but not least Assembler for each arch sucks

I know I forgot a lot of em but that's just what came to my mind

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List