constructors not allowed a return type

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    constructors not allowed a return type

    Hi,
    Code:
    //my_mysql.h
    #include "stdafx.h"
    #include <winsock2.h> 
    #include <mysql/mysql.h>
    #include "username_password.h"
    
    class my_mysql
    {
    private: 
    	username_password user_information;
    	MYSQL mySql;
    public:
    	my_mysql(username_password *user_info);
    	~my_mysql();
    }
    Code:
    #include "stdafx.h"
    //#include <mysql.h>
    #include "my_mysql.h"
    
    my_mysql::my_mysql(username_password *user_info)
    {
    	this->user_information=user_info;
    }
    
    my_mysql::~my_mysql()
    {
    
    }
    Code:
    //if requrired
    //a portion of username_password.cpp
    username_password username_password::operator =(username_password u_p)
    {
    	//username_password temp;
    	this->setPassword(u_p.getPassword());
    	this->setPortAddress(u_p.getPortAddress());
    	this->setServerAddress(u_p.getServerAddress());
    	this->setUserName(u_p.getUserName());
    	return *this;
    }
    
    username_password username_password::operator =(username_password *u_p)
    {
    	//username_password temp;
    	this->setPassword(u_p->getPassword());
    	this->setPortAddress(u_p->getPortAddress());
    	this->setServerAddress(u_p->getServerAddress());
    	this->setUserName(u_p->getUserName());
    	return *this;
    }
    returned error
    Code:
    1>------ Build started: Project: mysql_manager, Configuration: Debug Win32 ------
    1>Compiling...
    1>my_mysql.cpp
    1>c:\users\johny\desktop\softback\vc\mysql_manager\mysql_manager\my_mysql.cpp(6) : error C2533: 'my_mysql::{ctor}' : constructors not allowed a return type
    1>Build log was saved at "file://c:\Users\johny\Desktop\softback\vc\mysql_manager\mysql_manager\Debug\BuildLog.htm"
    1>mysql_manager - 1 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    There is no compilation error with the other files
    Error message flew over my head.
    Please let me know what am i missing.

    The entire source code is attached with the question

    Best Regards,
    Johny
    Attached Files
    Last edited by johny10151981; Jul 15 '10, 02:10 AM. Reason: One bug is fixed but reaining another
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    Bug fixed. forgot semicolon at the end of the class declaration in the header file

    Comment

    Working...