|
Hi so this is my first post here, I'm having the following problem
----------------------------------------------------------------------------------------------------
6 11 E:\Trabalhos\Programação\Projeto\Projeto.cpp [Error] expected constructor, destructor, or type conversion before '(' token
----------------------------------------------------------------------------------------------------
Here's the code:
#include <iostream>
#include <fstream>
#include <locale.h>
using namespace std;
setlocale (LC_ALL, "Portuguese");
ofstream ficheiro ("Info Trabalhador");
int x, i,a,b,d;
int esc[4] = {100, 150, 200, 250};
struct trab
{
char nome[100];
char morada[200];
int numero;
int telefone;
};
trab f;
int salario(int n1,int n2){
int money;
money = n1*n2;
return money;
}
void menu1 (){
cout<<" * * * * * * * * * * * * * * * * * * * *"<<endl;
cout<<" * 1. - Identificação *"<<endl;
cout<<" * 2. - Escalão Do Trabalhor *"<<endl;
cout<<" * 3. - Número De Horas Trabalhadas *"<<endl;
cout<<" * 4. - Salvar Ficheiro *"<<endl;
cout<<" * 5. - Sair *"<<endl;
cout<<" * * * * * * * * * * * * * * * * * * * *"<<endl;
}
int main (){
menu:
menu1();
cout<<endl;
cout<<"R: ";
cin>>x;
cout<<endl;
switch (x)
{
case 1:
cout<<"Qual o seu nome?"<<endl<<endl;
cout<<"R: ";
cin>>f.nome;
cout<<endl;
cout<<"Qual a sua morada?"<<endl<<endl;
cout<<"R: ";
cin>>f.morada;
cout<<endl;
cout<<"Qual o seu número?"<<endl<<endl;
cout<<"R: ";
cin>>f.numero;
cout<<endl;
cout<<"Qual o seu telemóvel?"<<endl<<endl;
cout<<"R: ";
cin>>f.telefone;
cout<<endl;
system("pause");
system("cls");
goto menu;
break;
case 2:
for (i=0; i<=4; i++)
{
cout<<i+1 <<". "<<esc[i]<<" euros/horas"<<endl;
cout<<endl;
}
cout<<"R: ";
cin>>a;
cout<<endl;
system ("Pause");
system ("cls");
goto menu;
case 3:
cout<<"Quantas horas trabalhou?"<<endl;
cout<<"R: ";
cin>>b;
if (a == 1)
{
d=100;
cout<<"Deve Receber: "<<salario(d,b)<<endl<<endl;
system ("Pause");
system ("cls");
goto menu;
}
else if (a == 2)
{
d=150;
cout<<"Deve Receber: "<<salario(d,b)<<endl<<endl;
system ("Pause");
system ("cls");
goto menu;
}
else if (a==3)
{
d=200;
cout<<"Deve Receber: "<<salario(d,b)<<endl<<endl;
system ("Pause");
system ("cls");
goto menu;
}
else
d=250;
cout<<"Deve Receber: "<<salario(d,b)<<endl<<endl;
system ("Pause");
system ("cls");
goto menu;
break;
case 4:
if(ficheiro.is_open())
{
ficheiro<<"Nome: "<<f.nome<<endl;
ficheiro<<"Morada: "<<f.morada<<endl;
ficheiro<<"Número: "<<f.numero<<endl;
ficheiro<<"Telemóvel: "<<f.telefone<<endl;
break;
}
case 5:
return 0;
break;
}
system ("Pause");
return 0;
}
Thanks for your help.
|
|
|
|
|
You are declaring local executable statements outside functions which is incorrect. You should move then inside an appropriate function, probably main .
modified 13-May-18 7:36am.
|
|
|
|
|
I have a small program. I compile the executable. If I find the executable
and double click on it, everything works fine. I can print, print preview; all is
well.
If within visual studio I hit the green triangle to run the executable and then I
try to print or print preview, I get an error in this code:
inline void* CThreadSlotData::GetThreadValue(int nSlot)
{
EnterCriticalSection(&m_sect);
ASSERT(nSlot != 0 && nSlot < m_nMax);
ASSERT(m_pSlotData != NULL);
ASSERT(m_pSlotData[nSlot].dwFlags & SLOT_USED);
ASSERT(m_tlsIndex != (DWORD)-1);
if( nSlot <= 0 || nSlot >= m_nMax )
{
LeaveCriticalSection(&m_sect);
return NULL;
}
CThreadData* pData = (CThreadData*)TlsGetValue(m_tlsIndex);
if (pData == NULL || nSlot >= pData->nCount)
{
LeaveCriticalSection(&m_sect);
return NULL;
}
void* pRetVal = pData->pData[nSlot];
LeaveCriticalSection(&m_sect);
return pRetVal;
}
It breaks at LeaveCriticalSection(). Im really perplexed as to why this error has arisen
and what to do to get it to go away. If you have any insight, please let me know.
|
|
|
|
|
It would help if you gave us the details of the error you're getting. There's no way we can guess.
Also, what line of code does it occur on? You have LeaveCriticalSection in three different lines.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
i am trying to make a game which requires a constant input from user, i looked through net but didn't understand it. How can i get an constant input from user while the program is running like
_kbhit_ does.
|
|
|
|
|
|
Hi,
I have a small project in vc++ 2015. While I calculate the total, I get this error.
Is it possible to solve this error. Any Kind helps.
private: static System::Decimal MyNumber2;
private: static System::Decimal DJSubTot = 0;
private: static System::Decimal DJVATTot = 0;
private: static System::Decimal DJFreightTot = 0;
MyNumber2 = 0;
if(Decimal::TryParse(textBox8->Text->Trim(), MyNumber2)){
DJVATTot = MyNumber2;
}
MyNumber2 = 0;
if (Decimal::TryParse(textBox9->Text->Trim(), MyNumber2)) {
if (MyNumber2>0) {
DJFreightTot = MyNumber2;
}
}
textBox10->Text = (DJSubTot + DJVATTot + DJFreightTot).ToString();
Thanks for the helps
|
|
|
|
|
I don't have C++/CLI, but converting that code to C# it works fine. Where does the error occur?
|
|
|
|
|
Thank Richard
textBox10->Text = (DJSubTot + DJVATTot + DJFreightTot).ToString();
The above line
Thank Again
|
|
|
|
|
I have had another look at the documentation and cannot see why the error occurs. As I already mentioned, I do not have C++/CLI (and don't want it) on my system, so cannot test it further.
|
|
|
|
|
It's ok Richard, Thank Again for reply
The following code clears my error()
textBox10->Text = Convert::ToString(Decimal::Add(Decimal::Add(DJSubTot, DJVATTot), DJFreightTot));
modified 13-Apr-18 21:22pm.
|
|
|
|
|
Hi,
I have a small project in VS2010 and its working fine. Now I am trying to upgrade to VS 2015 & Found Visual C++ by using creating project C++/Cli->UI->Windows Forms Applications.
I get struck in following simple codes, I cannot identify my mistake.
public ref class My_ProjectData
{
public:
static System::Data::DataTable^ UnitRateTbl = gcnew System::Data::DataTable();
public: static void MyUnitRate_Collect() {
String^ ICode=String::Empty;
for(int W1=0; W1<=UnitRateTbl->Rows->Count-1; W1++){
ICode=UnitRateTbl->Rows[W1]["itm_code"]->ToString(); }
};
Error : function "System::Data::DataRowCollection::default[int]::get" cannot be called with the given argument list
Thanks for the helps
|
|
|
|
|
I have looked at the documentation and cannot see an error in that line of code. However, I notice that you have declared UnitRateTbl as static , and wonder if that may be the problem.
|
|
|
|
|
Thank Richard,
I checked by Without static declaration, but still the error raised.
I assume that, we have to supply the datatype to that for loop variable [W1].[May be Not sure]
String^ ICode=String::Empty;
for(int W1=0; W1<=UnitRateTbl->Rows->Count-1; W1++){
ICode=UnitRateTbl->Rows[<int^>W1]["itm_code"]->ToString(); ??????????????
}
Thanks Again
|
|
|
|
|
That will not help since the data type is already defined in your for expression. You could try breaking the statement into its parts:
DataRow row = UnitRateTbl->Rows[W1];
ICode= row["itm_code"];
... and see what happens.
|
|
|
|
|
|
Okay ...I was working on making my own string class using dynamic memory allocation. The things were working fine. But when I sent the same code to one of my friends the code crashed. He was using the same compiler. The then copied pasted the same code in another source file, so it crashed. Then I changed the name of the original file, again program crashed. But I changed to name again to previous one and then again program was working fine. so whats this whole thing. c++.
P.S: I have dynamic memory and pointers.
|
|
|
|
|
Member 13767759 wrote: so whats this whole thing. You think we can somehow guess?
|
|
|
|
|
You should use "Remote Desktop" to dial into your friend's computer, do the "paste" thing, and then tell them what bozos they were for not following your instructions (assuming they work).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Hi,
I wish to convert from c# for the following codes contain get_Item & set_Value convertion in C++/Cli.
Code:
private static void SetWIAProperty(IProperties properties, object propName, object propValue)
{
Property prop = properties.get_Item(ref propName);
prop.set_Value(ref propValue);
}
Any guidences will be helpful.
Thanks Again
modified 9-Apr-18 12:19pm.
|
|
|
|
|
How to add columns dynamically to wpf datagrid in mvvm without using dependency proporties
|
|
|
|
|
|
Does anybody know how to detect when option -Gr is in effect? I mean there is (AFAICS)
no built-in define _Gr in such a case.
-- Gisle V.
|
|
|
|
|
Hi,
With the MSVC compiler you can do:
#ifdef _CPPRTTI
#endif
I think with GCC you can do:
#ifdef __GXX_RTTI
#endif
Best Wishes,
-David Delaune
|
|
|
|
|
Thanks, but RTTI and option -GR has nothing to do with option -Gr AFAICS.
-Gr is fastcall and -GR is to enable C++ RTTI.
-- Gisle V.
|
|
|
|