Trying to build a class with no property in it

I built a class that I will be accessed from another class (kinda like a record). I wanna start the class from nothing, but Delphi forces it to be a TObject. That would be ok if only there was no properties added to those I make. Is there anyway to make them disapear?
Here's a sample of my code:
    Ttest = Class
      Private
        function pGetProp: Byte;
        procedure pSetProp(const Value: Byte);

      Published
        Property MyProperty: Byte Read pGetProp Write pSetProp;


comptebidon81Asked:
Who is Participating?
 
ITugayConnect With a Mentor Commented:
Hi comptebidon81,

if you'd like to build it from "nothing" then "class" is wrong ancestor, because it has predefined members. Would be better build it something like this:

  TMyObj = object
  private
    FProp: Integer;
    procedure SetProp(I: Integer);
  public
    property Prop: Integer read FProp write SetProp;
  end;

------
Igor.
0
 
kretzschmarCommented:
? tobject didn't have propertys just methods

could you explain a bit more
0
 
comptebidon81Author Commented:
well, methods or properties, I don't wanna see them.
All I wanna see when I use my Class is the properties or Methods I defined.  (with the code completion)
I have to find a way either to hide those methods of the TObject, or to start my class out  of nothing.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
EpsylonCommented:
I don't think this is possible...
0
 
comptebidon81Author Commented:
What do you mean not possible?
TObject is a class. It was created out of nothing or at least has a Parent that was. If they managed to create it, why woudn't I be able to do the same?
0
 
EpsylonCommented:
If you define a new class like this

TMyObject = class     // no ancestor specified
  ...
end;

it will automatically be derived from TObject. This is what the manual says.
0
 
peymanzCommented:
It is not possible because, the delphi compiler is TObject aware. It forces all classes to be descendents of the TObject. However TObject does not have any properties. So all the properties you define are alone.

regards
// peymanz
0
 
comptebidon81Author Commented:
There might not be any properties, but there is a lot of functions and procedures like AfterConstruction and all those generally usefull things. Well, right now, their more anoying than usefull.

By the way, thanks for the explanation peymanz...
0
 
MadshiCommented:
You can use a stinky record or a pointer list to build a class like thing without additional methods/properties. But then Delphi doesn't know that it is a class like thing, so code completion doesn't work on it nor all the other things that Delphi tries to help class builders with.

If you want all those Delphi goodies, you have no choice than using the keyword "class". And in that case Delphi silently forces you to use TObject as the class parent. That's it. I'm sorry, you have no choice.

Regards, Madshi.
0
 
comptebidon81Author Commented:
So you say I have to choose between a record (wich will give me weeks and weeks of work) or to go on with the Class and try not to see those unwanted lines in the code completion?
 If only I could Hide them somehow. ...
0
 
Bill_DoorCommented:
if y're that concerned with your properties not being the only ones that come up, prefix them with and underscore (or whatever makes you comfortable) so they all come up in the same place.

An ugly solution I know....but y're trying to use the tool (Delphi) in a way it was not designed to be used.

Ed
0
 
MadshiCommented:
Maybe you can redeclare the methods/properties of TObject in your class, moving them to the private area. You'll get warnings as a result (but you can turn them off with a switch). In that case I guess that code completion will only show YOUR methods/properties, if code completion is used in a unit other than the one in that your object is defined. In the unit where your object is defined, you'll nevertheless see all methods.

I'm not sure if this idea would work at all, I've not tested it, it's just an idea...

Regards, Madshi.
0
 
comptebidon81Author Commented:
Thanks a lot, Igor! You saved me!
0
 
MadshiCommented:
Hmmm... Sorry for giving false information to you. I didn't remember this "object". Never used it...
0
 
ITugayCommented:
Madshi,
do you never use Turbo Pascal?
Sorry, just a joke :-)
------
Igor
0
 
MadshiCommented:
I used it some years ago, but I can't remember having used the keyword "object". At the Turbo Pascal times I had not much reason to do object oriented programming. There records just were perfect...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.