Thread: Simple Question

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    31

    Simple Question

    Code:
    const Matrix Matrix::operator+(const Matrix& rhs) const;
    Can someone explain to me what each const is for in this function prototype?
    Thanks.

    Pier.

  2. #2
    1.b4 e5 2.a3 d5 3.d4 exd
    Join Date
    Jan 2003
    Posts
    167
    Well, I thought it was a simple question too until I noticed the , then I got all confused. My compiler wont even accept that. :<
    AIM: MarderIII

  3. #3
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    The first const means it returns a constant matrix, the one in the parenthesis means that the matrix passed will remain constant throughout the function, and the one at the end means that the class itself will not be changed throughout the function.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple question regarding variables
    By Flakster in forum C++ Programming
    Replies: 10
    Last Post: 05-18-2005, 08:10 PM
  2. Simple class question
    By 99atlantic in forum C++ Programming
    Replies: 6
    Last Post: 04-20-2005, 11:41 PM
  3. Simple question about pausing program
    By Noid in forum C Programming
    Replies: 14
    Last Post: 04-02-2005, 09:46 AM
  4. simple question.
    By InvariantLoop in forum Windows Programming
    Replies: 4
    Last Post: 01-31-2005, 12:15 PM
  5. simple fgets question
    By theweirdo in forum C Programming
    Replies: 7
    Last Post: 01-27-2002, 06:58 PM