As title, I'm in Ca class defines a two-dimensional array of strings in a.h
Public:
Cstrings Shuzu [100] [100].
And for the assignment of the elements in an array in the a.c pp,
Now I want to call in another class Cb elements in the array of values, how to implement?
CodePudding user response:
In class Cb find Ca first instance of the class
CodePudding user response:
reference 1st floor schlafenhamster response: find Ca first in the class Cb class instances Excuse me specific how to achieve this, I compare food, can be said that detailed some CodePudding user response:
CodePudding user response:
CA g____a=new CA (); CB g____b; G___b. XXX (g___a - & gt; String); Something like this CodePudding user response:
The Cb constructor Cb: : Cb (Ca * pca) { M_pca=pca; } Cb: : aaa () { Cstrings s=pca - & gt; Shuzu [1] [1]. } CodePudding user response:
Cstrings Shuzu [100] [100]. Write a bit odd, MFC CStringArray string array class to use Refer to this: https://blog.csdn.net/thanklife/article/details/76836487 MFC_ca. H # pragma once //MFC_ca The class MFC_ca: public CWnd { DECLARE_DYNAMIC (MFC_ca) Public: MFC_ca (); Virtual ~ MFC_ca (); Int number; Cstrings shuzu;//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Protected: DECLARE_MESSAGE_MAP () }; MFC_ca. CPP //MFC_ca. CPP: implementation file // # include "PCH. H" # include "MFC_cab. H" # include "MFC_ca. H" //MFC_ca IMPLEMENT_DYNAMIC (MFC_ca, CWnd) MFC_ca: : MFC_ca () { Number=200; Shuzu="goodone";//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- } MFC_ca: : ~ MFC_ca () { } BEGIN_MESSAGE_MAP (MFC_ca, CWnd) END_MESSAGE_MAP () //MFC_ca message handler MFC_cb. H # pragma once //MFC_cb The class MFC_cb: public CWnd { DECLARE_DYNAMIC (MFC_cb) Public: MFC_cb (); Virtual ~ MFC_cb (); Cstrings cb1;//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- cb1 Protected: DECLARE_MESSAGE_MAP () }; MFC_cb. CPP //MFC_cb. CPP: implementation file // # include "PCH. H" # include "MFC_cab. H" # include "MFC_cb. H" # include "MFC_ca. H" //MFC_cb IMPLEMENT_DYNAMIC (MFC_cb, CWnd) MFC_cb: : MFC_cb () { MFC_ca ca1. Cb1=ca1. Shuzu;//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- this is the value of ca class get } MFC_cb: : ~ MFC_cb () { } BEGIN_MESSAGE_MAP (MFC_cb, CWnd) END_MESSAGE_MAP () //MFC_cb message handler