Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3751262
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:02:58+00:00 2026-05-19T09:02:58+00:00

I’m trying to translate some C++ code for a neural net into C#. I

  • 0

I’m trying to translate some C++ code for a neural net into C#. I first took the C++ code, from a 1993 book, and ran it. Then translated it using the STL and it ran again. Now I’m trying to get it into C# with Visual Web Developer 2008 Express.

The original code used “friend” classes and I’m just trying to do the same making everything “public”.

The following code compiles but only gives null references when run:

public class ineuron
{
     public Double weight, activation;

     public ineuron(Double set_wt)
     {
         weight = set_wt;
     }

…

 public class netwrk
 {
     public oneuron onrn;
     public ineuron in1, in2, in3, in4;

     public netwrk( Double inp_1, Double inp_2, Double inp_3, Double inp_4 )
     {
         ineuron in1 = new ineuron(inp_1);
         ineuron in2 = new ineuron(inp_2);

…

and later, in some code called by a button push:

netwrk ntw = new netwrk(i_n1, i_n2, i_n3, i_n4);

Unfortunately, trying to use ntw.in1.activation etc. leads to null reference runtime errors.

What am I forgetting to do?

Barney

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T09:02:59+00:00Added an answer on May 19, 2026 at 9:02 am

    When you do this:

    ineuron in1 = new ineuron(inp_1);
    

    You declare a new local variable that goes away when the constructor completes.

    If you want to refer to the class member in1, just go:

    in1 = new ineuron(inp_1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.