c++ - An error in the LinkList code -


.cpp file

#include "stdafx.h" #include "linkx.h" #include<iostream> #include<string.h> using namespace std;  linkx::linkx(int pid,char *pname) {     id=pid;     strcpy(name,pname);     next=null; }  void linkx::displaylink() {     cout<<id<<endl;     cout<<name<<endl; } 

the above code gets error :

error 3 error c2511: 'linkx::linkx(int,char *)' : overloaded member function not found in 'linkx'

    private: system::void button1_click(system::object^  sender, system::eventargs^  e) {              linkx *l1=new linkx(10,"charvi");              linkx *l2=new linkx(20,"vin");              l1->next=l2;               delete l1;              delete l2;          }     }; 

this code gets errors:

error 1 :error c2664: 'linkx::linkx(int,char)' : cannot convert parameter 2 'const char [7]' 'char' error 2 :error c2664: 'linkx::linkx(int,char)' : cannot convert parameter 2 'const char [4]' 'char'

what these errors mean ?

how can correct them?

these codes written in visual studio.

concerning first error,

did declare linkx::linkx(int pid,char *pname) constructor in class declaration (in linkx.h file)?

concerning second error:

your constructor ask char* variable, indicating needs modify it. when call it, use constant char arrays, cannot modified. has constructor not realy need modify pname variable, have change pname type const char* , ok.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -