Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6959733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:18:39+00:00 2026-05-27T15:18:39+00:00

I am trying to compile a class of mail sending using sockets However, I

  • 0

I am trying to compile a class of mail sending using sockets

However, I have that error during the compilation :

expected `)’ before ‘=’ token

At the line where I declare the constructor :

Mail(ipSMTP="serveurmail.com", port=25)

I’m suspecting that the issue is coming from the two string attributes declared before the Mail() constructor :

Here is the code of the mail.h file, containing the Mail class declaration :

#if defined (WIN32)
#include <winsock2.h>
typedef int socklen_t;
#elif defined (linux)
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define closesocket(s) close(s)
typedef int SOCKET;
typedef struct sockaddr_in SOCKADDR_IN;
typedef struct sockaddr SOCKADDR;
#endif

#include <string>
#include <iostream>


using namespace std;

class Mail
{
  private :

  public :
         SOCKET sock;
         SOCKADDR_IN sin;
         char buffer[255];
         int erreur;
         int port;
         string message;
         string ipSMTP;

          Mail(ipSMTP="serveurmail.com", port=25)
          {
               #if defined (WIN32)
                WSADATA WSAData;
                erreur = WSAStartup(MAKEWORD(2,2), &WSAData);
                 #else
                    erreur = 0;
                 #endif

               message = "";

               /* Création de la socket */
                sock = socket(AF_INET, SOCK_STREAM, 0);

                /* Configuration de la connexion */
                sin.sin_addr.s_addr = inet_addr(ipSMTP.c_str());
                sin.sin_family = AF_INET;
                sin.sin_port = htons(port);
          }

          ~Mail()
          {
               /* On ferme la socket précédemment ouverte */
                    closesocket(sock);

                    #if defined (WIN32)
                        WSACleanup();
                    #endif
          }

          void envoi()
          {
               //Instructions d'envoi d'email par la socket via le SMTP
          } 
};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:18:39+00:00Added an answer on May 27, 2026 at 3:18 pm

    You need to specify the types of your constructor arguments, as well as assigning your members with the passed values.

    Mail(ipSMTP="serveurmail.com", port=25)
    {
    

    should be written as

    Mail (string const& ipSMTP = "serveurmail.com", int port =25)
      : port (port), ipSMTP (ipSMTP) // constructor initializer list
    {
    

    In the above we are assigning the member variables using a constructor initializer list, you can read more about it here:

    [10.6] Should my constructors use “initialization lists” or “assignment”?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi trying the compile Objective C++/Protocol code but the compilation fails with error Expected
When trying to compile my class I get an error: The constant 'NamespaceName.ClassName.CONST_NAME' cannot
I'm trying to compile such code: #include <iostream> using namespace std; class CPosition {
I'm trying to compile a class Tmp that implements an interface TmpInter . /*
Im trying to compile a simple class library project,its from Source Safe. However,when i
I am trying to compile kmeans.java which uses a FloatArrayWritable class . I have
I am getting an error when trying to compile my class. The error: Matrix.cpp:13:
I am trying to compile some code where I have a class called Card.
I'm trying to compile AS files using the mxmlc but the particular class depends
i am trying to compile this very simple piece of code class myList {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.