Thread: Mingw not complaining

  1. #1
    ... arjunajay's Avatar
    Join Date
    May 2005

    Unhappy Mingw not complaining

    I'm using mingw gcc( compiler. In the following code I pass a variable 'q'as 'const' but I later use its private members in the '>>'operator (in the same function) which obviously modify it. but the compiler did'nt complain and the programm compiled. Later during execution when I used the '>>' operation, the program halted when it reached that point. Even though I understood the error and corrected it, what I don't understand is why the compiler did'nt yell at me.
    Does someone have a clue?

    //no #include iostream as it is included in the main file.
    using namespace std; //for the istream and ostream
    class Quaternion{
        long double a, b, c, d;
        Quaternion(long double aa=0, long double bb=0,
                   long double cc=0, long double dd=0):a(aa), b(bb), c(cc), d(dd){}
        virtual ~Quaternion(){}
        friend ostream& operator <<(ostream& out, const Quaternion& q){
            return out;
        friend istream& operator >>(istream& in, constQuaternion& q){
            in>>q.a>>q.b>>q.c>>q.d;//modifies q's members
            return in;
        Quaternion operator +(const Quaternion q){
            return Quaternion(a+q.a, b+q.b, c+q.c, d+q.d);
        Quaternion operator -(const Quaternion q){
            return Quaternion(a-q.a, b-q.b, c-q.c, d-q.d);
        void set(long double aa=0, long double bb=0,
                 long double cc=0, long double dd=0){
            //blah blah
        long double& operator [](unsigned int i){ //0 for 'a' component
           //blah blah
        Quaternion operator *(const Quaternion& q){
    using namespace std;
    int main(){
    Quaternion x, y;
    cout<<"x :";
    [b]cin>>x; //when here the program halts and terminates without any complaining.
    cout<<"y :";
    cout<<"x   :"<<x<<"\n"
        <<"y   :"<<y<<"\n"
        <<"x*y :"<<x*y<<"\n"
        <<"y*x :"<<y*x<<"\n";
    return 0;[b]

  2. #2
    Join Date
    May 2004
    Maybe you don't have all your compiler warnings on.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. MinGW thread-safe runtime libraries
    By Mario F. in forum C++ Programming
    Replies: 3
    Last Post: 08-21-2006, 08:15 AM
  2. Free compiler for commercial development? (mingw?)
    By kook44 in forum Windows Programming
    Replies: 8
    Last Post: 01-07-2006, 09:32 AM
  3. compiling mingw to enable timeSetEvent
    By underthesun in forum Windows Programming
    Replies: 2
    Last Post: 02-02-2005, 06:00 PM
  4. SDL and MinGW Studio
    By Vicious in forum Tech Board
    Replies: 0
    Last Post: 07-30-2004, 09:59 PM
  5. Convert Microsoft LIB to MingW compatible lib
    By tigs in forum Windows Programming
    Replies: 0
    Last Post: 07-20-2004, 06:53 PM