473,513 Members | 2,391 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

missing storage-class or type specifiers

39 New Member
Hi

this is the error that i am getting pls. help me out

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <vector>
  3. #include<windows.h>
  4. //#include "class.h"
  5. int flag =0;
  6.  
  7. class Cthread;
  8. template <typename T>
  9. class MyQueue
  10. {
  11.     CEvent *vent;
  12.     std::vector<T> data;
  13.   public:
  14.      MyQueue();
  15.      void Add(T const &);
  16.      void Remove();
  17.      void Print();
  18.      void run();
  19.      ~MyQueue();
  20. };
  21.  
  22. class Cthread
  23. {
  24.     MyQueue<int> q;    
  25. public:
  26.     Cthread(){}
  27.     Cthread(Cthread &t)
  28.     {
  29.         t.q.run();
  30.     }
  31.     void initialize();
  32.  
  33. };
  34.  
  35. template <typename T>
  36. MyQueue<T> ::MyQueue()
  37. {
  38.     //vent = new CEvent(false,false);
  39. }
  40.  
  41. template <typename T>
  42. MyQueue<T> ::~MyQueue()
  43. {
  44.     //CEvent::Unlock();
  45. }
  46.  
  47. template <typename T> void MyQueue<T> ::Add(T const &d)
  48. {
  49.     //if(vent->SetEvent())
  50.     {
  51.     data.push_back(d);
  52.     //vent->ResetEvent();
  53.     }
  54. }
  55.  
  56. template <typename T> void MyQueue<T>::Remove()
  57. {
  58.      std::cout<<data[0];
  59.      data.erase(this->data.begin( ) + 0,this->data.begin( ) + 1);
  60. }
  61.  
  62. template <typename T> void MyQueue<T>::Print()
  63. {
  64.      std::vector <int>::iterator It1;
  65.      It1 = data.begin();
  66.      for ( It1 = data.begin( ) ; It1 != data.end( ) ; It1++ )
  67.          std::cout << " " << *It1<<endl;
  68.  
  69. }
  70.  
  71. template <typename T> 
  72. void MyQueue<T>::run()
  73. {
  74.  
  75.     while(flag != 100)
  76.     {
  77.         std::cout<<"in run function\n";
  78.         if(flag == 1)
  79.         {
  80.             //Sleep(5000);
  81.             this->Remove();
  82.             flag = 0;
  83.             //vent->ResetEvent();
  84.         }
  85.         else
  86.         {
  87.             Sleep(1000);
  88.             continue;
  89.         }
  90.     }
  91.  
  92. }
  93.  
  94. void Cthread ::initialize()
  95. {
  96.     int data;
  97.     while(true)
  98.     {
  99.         std::cout<<"enter the data\n";
  100.         std::cin>>data;
  101.     if(data == 9999)
  102.         exit(0);
  103.     q.Add(data);
  104.     flag = 1;
  105.     }
  106.  
  107. }
  108.  
  109. void *ptr(Cthread &t)
  110. {
  111.     t.initialize();
  112.     return NULL;
  113. }
  114. void main()
  115. {
  116.      DWORD id;
  117.      HANDLE hthread;
  118.      std::cout<<"before object created\n";
  119.      Cthread t;
  120.      std::cout<<"after object created\n";
  121.      hthread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)ptr,&t,0,&id);
  122.      t = Cthread(t);
  123.      getchar();
  124.      getchar();
  125. }
  126.  
thanx in advance
Sep 26 '07 #1
5 4981
Savage
1,764 Recognized Expert Top Contributor
Only things I found odd are:

void Add(T const &);

this should be const T &)

and the line where you create a new thread.I don't see ptr anywhere defined.

Savage
Sep 26 '07 #2
diwakar09
39 New Member
Only things I found odd are:

void Add(T const &);

this should be const T &)

and the line where you create a new thread.I don't see ptr anywhere defined.

Savage
Thanx for gone through the code.
if i remove only
CEvent *vent;
statement every thing thing is going fine.

i want to use CEvent so that the two threads will synchronize,

ptr is a function returning void pointer defined at line no. 109. may be you missed that by chance.
please help me out.
Sep 26 '07 #3
weaknessforcats
9,208 Recognized Expert Moderator Expert
This code:
class Cthread;
template <typename T>
class MyQueue
{
CEvent *vent;
std::vector<T> data;
public:

won't compile becuse the compiler does not know about CEvent and therefore sees it as an invalid type.

Use a forward reference. That is enough information for the compiler to allow a pointer to a CEvent:
Expand|Select|Wrap|Line Numbers
  1. class CEvent;                     //forward reference
  2. class Cthread;
  3. template <typename T>
  4. class MyQueue
  5. {
  6.     CEvent *vent;
  7.     std::vector<T> data;
  8.   public:
  9.  
Sep 26 '07 #4
diwakar09
39 New Member
This code:



won't compile becuse the compiler does not know about CEvent and therefore sees it as an invalid type.

Use a forward reference. That is enough information for the compiler to allow a pointer to a CEvent:
Expand|Select|Wrap|Line Numbers
  1. class CEvent;                     //forward reference
  2. class Cthread;
  3. template <typename T>
  4. class MyQueue
  5. {
  6.     CEvent *vent;
  7.     std::vector<T> data;
  8.   public:
  9.  

thanx for your rply,
but it doesnot solve the problem
now i have got the answer
CEvent class is part of MFC,
and i am not using any MFC that's the problem
so i use CreateEvent() function and this solved the problem
By making it forward reference we have to define the class, in the program
but CEvent is part of MFC.
which is already defined somewhere in some particular file.

Again thanx a lot
Sep 27 '07 #5
weaknessforcats
9,208 Recognized Expert Moderator Expert
CEvent class is part of MFC,
and i am not using any MFC that's the problem
so i use CreateEvent() function and this solved the problem
By making it forward reference we have to define the class, in the program
but CEvent is part of MFC.
which is already defined somewhere in some particular file.
Not unless you have included an MFC header. Like, you created a Win32 application and asked for MFC support.

The CEvent forward reference will work.

You should post your stdafx.h
Sep 27 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2703
by: Bas Wassink | last post by:
Hello there, I'm having trouble understanding a warning produced by 'splint', a code-checker. The warning produced is: keywords.c: (in function keyw_get_string) keywords.c:60:31: Released...
0
2226
by: Ryan | last post by:
I'm writing a utility that needs to be aware of media (CD, DVD, Zip disk, usb stick, etc) insertions and removals. Which seems to be more of a problem than I original imagined. I can't use any...
8
1466
by: Glenn Thimmes | last post by:
I am needing to read and write application settings from within my ASP.NET application. My web.config is not an option since I need to be able to write settings as well. My database is not an...
1
1367
by: Gerald Hernandez | last post by:
The .NET Framework is huge, and either this isn't in there, or I'm just missing it... Are there any built-in methods to work with OLE2 Structured Storage files? Or am I stuck with using COM...
1
2350
NeoPa
by: NeoPa | last post by:
My workstation at work is a Windows 2000 Server with Terminal Services as I need to connect into it remotely (Pre XP - much easier nowadays). I'm also using Outlook 2000. I'm migrating all my users...
0
449
by: zhensoftware | last post by:
USB storage devices have gained popularity. It can be host to viruses, Trojans, hacker toolkits, worms or other forms of malicious programs. For example, when you plug your USB disk into a computer...
4
6474
by: =?Utf-8?B?SnVhbiBEZW50?= | last post by:
Hi, I am getting the following in a VC++ EXE (using VS2005) that links several C++ DLLs and uses MFC and ATL, when I try to start it under the debugger: ------- 'Exactus.UX.Studio.v1.exe':...
6
5095
by: cristizaharioiu | last post by:
Hello, I am beginner with db2 ( DB2 v9.1.0.1 running on RHEL 4); this is my first post. I have this error " SQL0968C The file system is full. SQLSTATE=57011"" in my instance configured with...
7
1462
by: Fred Blair | last post by:
I have been having trouble with SQL Express, getting it installed, etc. I am trying to work on an application that will give a test to only one student at a time. It will have 50 multiple choice...
0
1276
by: DB2 Dufus | last post by:
Hi i am new to the DB2 world and i am trying to figure out how DB2 stores data in containers/tablespaces in all the forums / documnetation from IBM i have read for a 4k pagesize the maximum...
0
7265
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7171
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7388
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7111
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7539
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5095
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4751
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1605
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
461
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.