Solved

Syntax Error: illegal use of this type as an expression

Posted on 2002-05-07
4
1,095 Views
Last Modified: 2008-03-04
Hi, syntax gurus out there,  I'm trying to use multidimensional WCHAR arrays in VC++, but have run into problems.

Code follows:

struct SnapinData {
    LPWSTR* lpwConnect;
public:
   
    SnapinData() : lpwConnect(NULL) {}
     ~SnapinData(){if(lpwConnect)delete [] lpwConnect;}
};



SnapinData* CServer::GetSnapinData()
{
     
     // Copy all the strings to a wchar array structure
     m_SnapInData.lpwConnect = new WCHAR*[m_saConnect.size()];

     for(INT i=0; m_saConnect.end(); i++)
     {
          m_SnapInData.lpwConnect[i] = new WCHAR[MAX_PATH];
          wcscpy(SnapinData.lpwConnect[i], m_saConnect.at(i).data());
     }

     return &m_SnapInData;
}

I get this error when i try to compile the code:



Compiling...
server.cpp
H:\c++\WksnMgmt\server.cpp(171) : error C2275: 'SnapinData' : illegal use of this type as an expression
        h:\c++\wksnmgmt\server.h(15) : see declaration of 'SnapinData'


Can anyone see the reason for the compile error?
0
Comment
Question by:ossentoo
  • 3
4 Comments
 
LVL 6

Accepted Solution

by:
snoegler earned 50 total points
ID: 6993410
wcscpy(SnapinData.lpwConnect[i], m_saConnect.at(i).data());

should be

wcscpy(m_SnapinData.lpwConnect[i], m_saConnect.at(i).data());
0
 
LVL 6

Expert Comment

by:snoegler
ID: 6994738
Topic still alive?
0
 

Author Comment

by:ossentoo
ID: 6995713
very stupid question i asked.  couldn't see error though!  Thanks a lot
0
 
LVL 6

Expert Comment

by:snoegler
ID: 6995882
:)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question