CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Dec 2013
    Posts
    75

    Compiler says cctor's definition does not match it's prototype

    This is very strange. The compiler says my Rotor's cctor's definition doesn't match it's prototype. I can't figure out what I'm doing wrong.

    Also, how can I convert my for loops into foreach loops?

    Attached is the project.

    Thanks!
    Attached Files Attached Files

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: Compiler says cctor's definition does not match it's prototype

    Code:
    Rotor(Rotor& rhs);
    Code:
    Rotor::Rotor(const Rotor& rhs)
    The prototype declaration is different from its definiton - the definiton is const whereas the declaration prototype isn't.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  3. #3
    Join Date
    Dec 2013
    Posts
    75

    Re: Compiler says cctor's definition does not match it's prototype

    Quote Originally Posted by 2kaud View Post
    Code:
    Rotor(Rotor& rhs);
    Code:
    Rotor::Rotor(const Rotor& rhs)
    The prototype declaration is different from its definiton - the definiton is const whereas the declaration prototype isn't.
    I fixed that...still get an error.

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Compiler says cctor's definition does not match it's prototype

    Quote Originally Posted by TSLexi View Post
    I fixed that...still get an error.
    Post the current definition and prototype.

  5. #5
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: Compiler says cctor's definition does not match it's prototype

    Quote Originally Posted by GCDEF View Post
    Post the current definition and prototype.
    ...and the error it is reporting.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  6. #6
    Join Date
    Dec 2013
    Posts
    75

    Re: Compiler says cctor's definition does not match it's prototype

    Strange...It compiles now.

    Also, since Rotor and Enigma are tightly coupled, should I declare Rotor within Enigma's private section? A Rotor is completely useless without an Enigma.
    Last edited by TSLexi; December 30th, 2013 at 08:46 AM.

  7. #7
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: Compiler says cctor's definition does not match it's prototype

    ...and the error that is being reported?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  8. #8
    Join Date
    Jul 2005
    Location
    Netherlands
    Posts
    2,042

    Re: Compiler says cctor's definition does not match it's prototype

    Quote Originally Posted by TSLexi View Post
    Also, since Rotor and Enigma are tightly coupled, should I declare Rotor within Enigma's private section? A Rotor is completely useless without an Enigma.
    Making Rotor a private nested class in Enigma means that only member functions and friends of Enigma can use the Rotor class. Not sure if that's what you want. If it is, you should consider whether it is possible to keep the Rotor class out of the Enigma header completely and define it in an anonymous namespace in Enigma.cpp.

    If you are thinking of making Rotor a public nested class in Enigma, then your question is really a matter of taste, IMO. Using a nested class can prevent the class name from polluting the enclosing namespace. However, it can also make type names pretty long, which makes your code harder to read and it introduces a dependency on the enclosing class whenever the type is needed. I.e. you cannot forward declare a nested class without defining the enclosing class.
    Cheers, D Drmmr

    Please put [code][/code] tags around your code to preserve indentation and make it more readable.

    As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky

  9. #9
    Join Date
    Dec 2013
    Posts
    75

    Re: Compiler says cctor's definition does not match it's prototype

    Rotor can only be used by Enigma, so making it private would give me the desired effect.

    Refresh me on anonymous namespaces.

  10. #10
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: Compiler says cctor's definition does not match it's prototype

    An Unnamed namespace (eg an anonymous namespace) is a namespace defined without a name.
    See http://msdn.microsoft.com/en-us/library/yct4x9k5.aspx
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured