Error C2512: no appropriate default constructor... (Tricky)

This is a discussion on Error C2512: no appropriate default constructor... (Tricky) within the C++ Programming forums, part of the General Programming Boards category; Hi... Can someone help me resolve VS 2008 error C2512: no appropriate default constructor available? Being sort of a newbie, ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    3

    Unhappy Error C2512: no appropriate default constructor... (Tricky)

    Hi...

    Can someone help me resolve VS 2008 error C2512: no appropriate default constructor available? Being sort of a newbie, I was unsuccessful in obtaining an answer via FAQs.

    Source file:

    #include "MGRS.h"

    ...

    int main(int argc, char* argv[])

    {

    ...

    MGRS CFG; // Line 375
    MGRSorUSNGCoordinates* mgrs_coord = CFG.convertFromGeodetic(geodeticCoordinates, Precision ); // Line 376

    ...

    mgrs.cpp(375) : error C2512: 'MSP::CCS::MGRS' : no appropriate default constructor available)

    Header file MGRS.h:

    ...

    #include "CoordinateSystem.h"

    namespace MSP
    {
    namespace CCS
    {
    class UPS;
    class UTM;
    class EllipsoidParameters;
    class MGRSorUSNGCoordinates;
    class GeodeticCoordinates;
    class UPSCoordinates;
    class UTMCoordinates;

    class MGRS : public CoordinateSystem

    {

    public:

    MGRS( double ellipsoidSemiMajorAxis, double ellipsoidFlattening, char* ellipsoidCode );


    MGRS( const MGRS &m );


    ~MGRS( void );


    MGRS& operator=( const MGRS &m );

    EllipsoidParameters* getParameters() const;

    MSP::CCS::MGRSorUSNGCoordinates* convertFromGeodetic( MSP::CCS::GeodeticCoordinates* geodeticCoordinates, long precision );

    ...


    Thanks
    Bob

  2. #2
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    611
    Quote Originally Posted by 4g_pull View Post
    MGRS( double ellipsoidSemiMajorAxis, double ellipsoidFlattening, char* ellipsoidCode );
    This constructor takes 3 arguments

    MGRS CFG; // Line 375
    You are providing none.

    You either have to give CFG constructor the three arguments it requires, or create another constructor that can be called without arguments. You lose the default no-argument constructor as soon as you create a user defined one.

    Also use code tags, like it says in this easy to miss thread << !! Posting Code? Read this First !! >>
    Last edited by adeyblue; 02-08-2011 at 03:40 PM. Reason: Haven't said constructor enough

  3. #3
    Registered User
    Join Date
    Feb 2011
    Posts
    3
    It worked. Thanks!

    MGRS CFG( semiMajorAxis, flattening, ellipsoidCode );
    MGRSorUSNGCoordinates* mgrs_coord = CFG.convertFromGeodetic( geodeticCoordinates, Precision );

  4. #4
    Registered User
    Join Date
    Mar 2011
    Posts
    4
    I am having some issues as well:

    Code:
    	MSP::CCS::MGRS l_MGRS( 6378137., 1.0 / 298.257223563, "WE" );
    	MSP::CCS::GeodeticCoordinates l_GeodeticCoordinates( MSP::CCS::CoordinateType::transverseMercator, -98, 38, 0 );
    
    	MSP::CCS::MGRSorUSNGCoordinates *l_MGRSorUSNGCoordinates = l_MGRS.convertFromGeodetic( &l_GeodeticCoordinates, 10 );
    	// 'MSP::CCS::CoordinateConversionException'
    The last function returns with a CoordinateConversionException. Everything seems in order, not sure what the issue is. Help?

    OSX 10.6.6
    Xcode 3.2.5
    Obj C++

    Thomas

  5. #5
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,554
    You failed to mention the error.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Registered User
    Join Date
    Mar 2011
    Posts
    4
    Quote Originally Posted by Elysia View Post
    You failed to mention the error.
    Code:
    terminate called after throwing an instance of 'MSP::CCS::CoordinateConversionException'
    Program received signal:  “SIGABRT”.
    thanks!

  7. #7
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    The description tells that you didn't define the constructor as you are using it...
    Forexample, if you have defined copy or parametrized constructor, and not default, it should generate an error... So, see clearly...

  8. #8
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,554
    Quote Originally Posted by Mr.777 View Post
    The description tells that you didn't define the constructor as you are using it...
    Forexample, if you have defined copy or parametrized constructor, and not default, it should generate an error... So, see clearly...
    What? You mean this error...
    terminate called after throwing an instance of 'MSP::CCS::CoordinateConversionException'
    ...is because of some constructor?

    The error is because you aren't using the class correctly. How it should be properly used is best commented on by someone who has read the documentation for the library.
    Since I don't have, nor have any link, I am not qualified to say what's wrong.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    Registered User
    Join Date
    Mar 2011
    Posts
    4
    As it turned out I was using a precision of '10' ( 5 easting, 5 northing ) which is how the military refers to it. In the case of this library it wants the precision of one axis so the precision I was looking for was 5.

    Thomas

  10. #10
    Registered User
    Join Date
    Mar 2011
    Posts
    4

    Validating MGRS Coordinates

    Is there a way with geotrans 3.1 to validate an MGRS coordinate string before attempting conversions ( which in my case crashes ugly )?

    thanks!
    Thomas

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Utilizing another compiled program for a task.
    By kotoroshinoto in forum C Programming
    Replies: 6
    Last Post: 06-03-2008, 01:43 PM
  2. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 04:42 PM
  3. A question about constructors...
    By Wolve in forum C++ Programming
    Replies: 9
    Last Post: 05-04-2005, 04:24 PM
  4. Help with default parameter value using ptr-to-functor
    By registering in forum C++ Programming
    Replies: 2
    Last Post: 03-24-2004, 03:21 PM
  5. Switching Default Buttons :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 07-02-2002, 04:08 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21