Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

What's wrong?

Posted on 1997-11-27
8
434 Views
Last Modified: 2008-02-26
What's wrong with the following statement?

public:
    CTypedPtrArray<CObArray, CTypedPtrArray<CObArray, MyObject&>&> My2DObArray;

I get missing "decl-specifiers" error, "syntax error : missing ';' before '<'", "unexpected token(s) preceding ';'". The lines are from my header file of my control. I add these lines after the lines generate by MSVC. I get errors even if I use 1D CArrays of CString there! Why?
0
Comment
Question by:sccheung
8 Comments
 
LVL 2

Expert Comment

by:rigansen
ID: 1174278
I've never seen something like that declaration before, think there're a lot of typos in that declaration, besides "CTypedPtrArray<CObArray" appeards two times.

anyway, CTypedPtrArray and MyObject seems to be a type variable (as int or char). CObArray and My2DObArray seems to be variables, but not sure at all!!

try searching for the declaration of the type variables.

if you need some more help try posting those declaration, and a piece of code that shows the use of CObArray and My2DObArray in action... ok!?

rigansen.
0
 

Expert Comment

by:lbrucher
ID: 1174279
Try to add spaces before and/or after the brackets.
I've had similar problem before and it helped.

Laurent.

0
 

Author Comment

by:sccheung
ID: 1174280
I'm very sorry to tell you that it doesn't work. It seems that you need more information. I give you the entire header file:


//Header file starts here:
#if !defined(AFX_MAGICSQUARENUMBERBLOCKCONTAINERCTL_H__0FA1C38C_6688_11D1_A3CF_E58E3C69845A__INCLUDED_)
#define AFX_MAGICSQUARENUMBERBLOCKCONTAINERCTL_H__0FA1C38C_6688_11D1_A3CF_E58E3C69845A__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

// MagicSquareNumberBlockContainerCtl.h : Declaration of the CMagicSquareNumberBlockContainerCtrl ActiveX Control class.

/////////////////////////////////////////////////////////////////////////////
// CMagicSquareNumberBlockContainerCtrl : See MagicSquareNumberBlockContainerCtl.cpp for implementation.

class CMagicSquareNumberBlockContainerCtrl : public COleControl
{
      DECLARE_DYNCREATE(CMagicSquareNumberBlockContainerCtrl)

// Constructor
public:
      CMagicSquareNumberBlockContainerCtrl();

// Overrides
      // ClassWizard generated virtual function overrides
      //{{AFX_VIRTUAL(CMagicSquareNumberBlockContainerCtrl)
      public:
      virtual void OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid);
      virtual void DoPropExchange(CPropExchange* pPX);
      virtual void OnResetState();
      //}}AFX_VIRTUAL

// Implementation
protected:
      ~CMagicSquareNumberBlockContainerCtrl();

      DECLARE_OLECREATE_EX(CMagicSquareNumberBlockContainerCtrl)    // Class factory and guid
      DECLARE_OLETYPELIB(CMagicSquareNumberBlockContainerCtrl)      // GetTypeInfo
      DECLARE_PROPPAGEIDS(CMagicSquareNumberBlockContainerCtrl)     // Property page IDs
      DECLARE_OLECTLTYPE(CMagicSquareNumberBlockContainerCtrl)            // Type name and misc status

// Message maps
      //{{AFX_MSG(CMagicSquareNumberBlockContainerCtrl)
            // NOTE - ClassWizard will add and remove member functions here.
            //    DO NOT EDIT what you see in these blocks of generated code !
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()

// Dispatch maps
      //{{AFX_DISPATCH(CMagicSquareNumberBlockContainerCtrl)
      short m_blockSize;
      afx_msg void OnBlockSizeChanged();
      short m_blocksPerRow;
      afx_msg void OnBlocksPerRowChanged();
      short m_blocksPerColumn;
      afx_msg void OnBlocksPerColumnChanged();
      //}}AFX_DISPATCH
      DECLARE_DISPATCH_MAP()

      afx_msg void AboutBox();

// Event maps
      //{{AFX_EVENT(CMagicSquareNumberBlockContainerCtrl)
      //}}AFX_EVENT
      DECLARE_EVENT_MAP()

// Dispatch and event IDs
public:
      enum {
      //{{AFX_DISP_ID(CMagicSquareNumberBlockContainerCtrl)
      dispidBlockSize = 1L,
      dispidBlocksPerRow = 2L,
      dispidBlocksPerColumn = 3L,
      //}}AFX_DISP_ID
      };

// The 2D object array of number block
public:
//problem begins here
      CTypedPtrArray< CObArray, CTypedPtrArray< CObArray, CMagicSquareNumberBlocks& >& > TheNumberBlocks;
//problem ends here
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MAGICSQUARENUMBERBLOCKCONTAINERCTL_H__0FA1C38C_6688_11D1_A3CF_E58E3C69845A__INCLUDED)

//Header file ends here.

That line is to declare a 2D array of number block which is a CObject containing the value of the block. That TObject is also responsible for displaying the block. As I want to let the user to pull the blocks is the game, the blocks have to be individual CObjects. In fact, that CObject is a ActiveX Control written with the ActiveX ControlWizard. I want to tell you that I know Delphi but is new to MSVC++. I make this program to get used to VC. Therefore the problems may be caused by some very silly mistakes. If anyone knows a better solution to this problem then declaring a 2D Object Array, you may also tell me. However, I find both CTypedPtrArray and 2D array very useful and I want to learn how to use both of them at the same time.

It's quite inconvenient to write "xxx start here" and "xxx ends here". Do you know how to use bold or italic in experts exchange?
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Expert Comment

by:tulin
ID: 1174281
Try to use pointer instead of reference!
CTypedPtrArray< CObArray, CTypedPtrArray< CObArray, CMagicSquareNumberBlocks* >* > TheNumberBlocks;
0
 

Author Comment

by:sccheung
ID: 1174282
Trying... Please wait for a minute.
0
 

Author Comment

by:sccheung
ID: 1174283
The same error still occur! Is this question too difficult? Should I use another method besides OBArray to solve this problem?
0
 

Author Comment

by:sccheung
ID: 1174284
I suceeded at last! I have been trying to fix this error for over a week. I am so excited when MSVC++ reports "0 errors, 0 warnings". With reference to the collect sample from MFC, I know that I have to add #include <afxtmpl> in the file stdafx.h to include the template support including the CTypedPtrArray. As I have told you before, the problem is caused by my lack of basic MFC knowledge. But why is there no book or MFC help file which tell me about this?
After adding this line, I find that I still have to take Tulin's advice and change it into pointer. Therefore, I would like to give the points to Tulin despite the fact that he cannot solve my problem completely. Tulin, please re-send your answer to let me grade it and give you the points.
0
 
LVL 1

Accepted Solution

by:
tulin earned 10 total points
ID: 1174285
Congratulation!
I paid attantion that when I've compiled your fragment
I got other error than you described. When you tried to
fix the problem following my advice and it didn't work,
I was almost sure that the problem is not exactly in the
line where you got the error.
  So, I resend my answer.

Regards! (waiting for new questions:-)
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Find Visual Studio Tools 2 111
VS2015 Redefinition errors 4 68
Autosar OS Multicore Share Resources confusion ? 2 70
find Speed using GPS latitude & longitude 4 41
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

808 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