Solved

Syntax Error: illegal use of this type as an expression

Posted on 2002-05-07
4
1,079 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

747 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

11 Experts available now in Live!

Get 1:1 Help Now