Error C2248 Help!!!

Discussion in 'C' started by liverbird, Feb 8, 2009.

  1. liverbird

    liverbird New Member

    Joined:
    Feb 8, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    I have 7 forms in my project. Form 6 has a text box, I wish for the text entered in Form 6 to be passed to a label in Form 7. I am new to C++ and would really appreciate any advice. I have posted the code I am trying to work with but i keep getting error C2248. Please Help!! Thanks.
    Code:
    public ref class Form6 : public System::Windows::Forms::Form
    {
    public:String^str1;
    
    public: 
    
    Form6(void)
    
    
    {
    
    InitializeComponent();
    //
    //TODO: Add the constructor code here
    //
    }
    #pragma endregion
    private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
    
    Application::Exit();
    }
    private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
    
    Application::Exit();
    }
    private: System::Void label2_Click(System::Object^ sender, System::EventArgs^ e) {
    }
    private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
    
    this->textBox2->Text = this->textBox1->Text;
    this->textBox1->Text = "";
    this->textBox1->Text = "Saved";
    } 
    private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
    }
    public: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {
    str1 = this->textBox2->text;
    Form6::Hide();
    Form7 myForm;
    if(myForm.ShowDialog() == System::Windows::Forms::DialogResult::OK)
    
    {
    //Do stuff
    }
    }
    private: System::Void Form6_Load(System::Object^ sender, System::EventArgs^ e) {
    str1 = "str1default";
    }
    private: System::Void textBox2_TextChanged(System::Object^ sender, System::EventArgs^ e) {
    str1=textBox2->Text;
    }
    };
    }
     
    Last edited by a moderator: Feb 9, 2009
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Compiler Error C2248

    Error Message
    'member' : cannot access 'access' member declared in class 'class'


    Which line throws the error?
     
  3. liverbird

    liverbird New Member

    Joined:
    Feb 8, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    Thanks very much for replying. As you can see I am new to this!! I really appreciate your feedback. I have copied the line (Line 281) which throws the error below:

    public: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {
    this->textBox2->text=str1;//this line throws the C2248 error
    Form6::Hide();
    Form7 myForm;
    if(myForm.ShowDialog() == System::Windows::Forms::DialogResult::OK)
    {
    //Do stuff
    }
     
  4. asadullah.ansari

    asadullah.ansari TechCake

    Joined:
    Jan 9, 2008
    Messages:
    356
    Likes Received:
    14
    Trophy Points:
    0
    Occupation:
    Developer
    Location:
    NOIDA
    My windows system is hanged.... I cannt test..
     
    Last edited: Feb 9, 2009
  5. liverbird

    liverbird New Member

    Joined:
    Feb 8, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    I have changed "public" to "private" which has solved the C2248 error Thanks.
    My problem now is when debugging I click to load Form7 which should have the text from Form6 but there is nothing there not even the textbox?? If you can offer me any advice that would be great.

    Thanks
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice