Solved

Syntax Error: illegal use of this type as an expression

Posted on 2002-05-07
4
1,088 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now