Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
| Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 29th, 2008, 07:51 AM
Registered User
 
Join Date: Apr 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Constructors

I have a classA with Privateconstructor and a method called addition
I have another classB with Protected Constructor and a method subtract

Ihave a classC with default constructor
Iam not abel to access methods of ClassA and ClassB

Please helpmeout


Madhuri
  #2 (permalink)  
Old April 29th, 2008, 07:54 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hampshire, United Kingdom.
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

How about you help us out by actually showing us some of your code?

The most likely reason is that you have not declared your classes as public, and they are outside of each others scope..

Rob
http://robzyc.spaces.live.com
  #3 (permalink)  
Old April 29th, 2008, 08:11 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Also, if class A and class B have private or protected constructors then you wont be able to create instances of them, so you'd need to mark the methods Addition and Subtract as static.

Show us some code, and explain why you have marked the constructors as private and protected will better help us work out what you should be doing.

/- Sam Judson : Wrox Technical Editor -/


Similar Threads
Thread Thread Starter Forum Replies Last Post
Constructors - instantiation brysora C# 2005 1 September 3rd, 2007 08:45 PM
Cascading Constructors rodmcleay General .NET 4 May 18th, 2007 03:57 AM
Private members in constructors shortt BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 2 May 16th, 2005 03:03 PM
COPY CONSTRUCTORS gbilios C++ Programming 4 April 30th, 2004 02:51 AM
Static Constructors Ibn_Aziz C# 3 December 25th, 2003 04:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.