Note that there are some explanatory texts on larger screens.

plurals
  1. PO'Error: expected a type' creating a new instance
    primarykey
    data
    text
    <p>i have a problem, i hope you can help me. I'm creating a C++ program which is running on linux. I just defined two classes, which the main one is called Downloader and looks like this:</p> <pre><code> #ifndef __DOWNLOADER_H__ #define __DOWNLOADER_H__ #include "configDownloader.h" #include "mailServer.h" #include &lt;logger.h&gt; using namespace ObjectModel; namespace Downloader { class Downloader { private: ... MailServer *m_mailServer; public: Downloader(char* configFileName); ... }; } #endif </code></pre> <p>In the constructor of the class, i tried to create a new instance of the class MailServer, which i defined into the same Namespace. The code of MailServer looks this way:</p> <pre><code>#ifndef __MAILSERVER_H__ #define __MAILSERVER_H__ #include &lt;stdio.h&gt; #include &lt;list&gt; #include &lt;mail.h&gt; using namespace std; using namespace ObjectModel; namespace Downloader { class MailServer { private: list&lt;Mail&gt; m_mails; char *m_username; char *m_password; public: MailServer(); ~MailServer(); void Open(char *username,char *password); bool SaveEmails(char *pathFiles); void Close(); }; } #endif </code></pre> <p>The constructor of this class is defined correctly into the .cpp file, and everything seems correct... The problem is that when i try to create a new instance of MailServer inside the constructor of Downloader, the compiler says <strong>"error: expected a type"</strong></p> <pre><code>#include &lt;stdio.h&gt; #include "downloader.h" #include &lt;unistd.h&gt; namespace Downloader { Downloader::Downloader(char* fileName) { this-&gt;m_config = new ConfigDownloader(fileName); this-&gt;m_log = new Logger("Log",LOG_LEVEL_INFO,0); this-&gt;m_mailServer = new MailServer();//the compiler shows the error right here } ... </code></pre> <p>any ideas??... i read somewhere that it could be that the compiler is too old, but i don't feel really comfortably coding inside the makefile.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload